Skip to content

Commit 038c1eb

Browse files
Update readme.
1 parent 969c8f5 commit 038c1eb

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

README.md

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
# lazy-proxy-autofac
2-
Lazy injection for Autofac container
1+
# Lazy injection for Autofac container
2+
3+
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+
var containerBuilder = new ContainerBuilder();
11+
containerBuilder.RegisterLazy<IFoo, Foo>();
12+
var container = containerBuilder.Build();
13+
14+
Console.WriteLine("Resolving service...");
15+
var foo = 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

Comments
 (0)