You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A [LazyProxy](https://github.com/servicetitan/lazy-proxy) can be used for IoC containers to change the resolving behaviour.
4
+
5
+
Dependencies registered as lazy are created as dynamic proxy objects built in real time, but the real classes are resolved only after the first execution of proxy method or property.
6
+
7
+
Also dynamic lazy proxy allows injection of circular dependencies.
8
+
9
+
```C#
10
+
varcontainerBuilder=newContainerBuilder();
11
+
containerBuilder.RegisterLazy<IFoo, Foo>();
12
+
varcontainer=containerBuilder.Build();
13
+
14
+
Console.WriteLine("Resolving service...");
15
+
varfoo=container.Resolve<IFoo>();
16
+
17
+
Console.WriteLine("Bar execution...");
18
+
foo.Bar();
19
+
20
+
// Resolving service...
21
+
// Bar execution...
22
+
// Hello from ctor
23
+
// Hello from Bar
24
+
25
+
```
26
+
27
+
## License
28
+
29
+
This project is licensed under the Apache License, Version 2.0. - see the [LICENSE](https://github.com/servicetitan/lazy-proxy-unity/blob/master/LICENSE) file for details.
0 commit comments