-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
909983f
commit 10cfa67
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,38 @@ | ||
# simple-object-factory | ||
Simple Object Factory to support Dependency Injection pattern in .NET | ||
|
||
Simple Object Factory supports Dependency Injection pattern in .NET. SOF simplifies creation of types with chained dependencies. SOF is reflection-based constructor-injection library. | ||
|
||
Usage: | ||
|
||
// Class definitions: | ||
|
||
public class Foo | ||
{ | ||
} | ||
|
||
public class Bar | ||
{ | ||
public Bar(Foo foo) | ||
{ | ||
} | ||
} | ||
|
||
public class Baz | ||
{ | ||
public Baz(Bar bar) | ||
{ | ||
} | ||
} | ||
|
||
// Instantiate ObjectFactory and register types | ||
|
||
ObjectFactory objectFactory = new ObjectFactory(); | ||
objectFactory.RegisterType<Foo>(); | ||
objectFactory.RegisterType<Bar>(); | ||
objectFactory.RegisterType<Baz>(); | ||
|
||
// Automatically instantiate registered types | ||
|
||
Foo foo = objectFactory.GetInstance<Foo>(); | ||
Bar bar = objectFactory.GetInstance<Bar>(); | ||
Baz baz = objectFactory.GetInstance<Baz>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters