GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — General definition binding General definition binding
Wojtek edited this page
By default, Setter Injection or Constructor Injection methods allows to bind target property/argument to value, object reference or inline object definition using predefined methods like ToValue(), ToInlineDefinition() or ToRegisteredXXX(). Spring.FluentContext is offers also to use more generic (and extendable) method to bind dependencies, which is To() method, accepting parameter of IDefinition<T> type. This method allows to bind target property/argument to any definition that matches to target type. Currently there are two classes offering IDefinition<T> implementations: IObjectRef<T> and Def class. The IObjectRef<T> implements now IDefinition<T> itself, so it can be used with To() method to define a reference to other object in context. The Def class that offers various types of definitions, such as:
The collection definitions are descried in next chapter. Def.ObjectProperty() method allows to configure object dependencies with property value of other registered object: ctx.RegisterDefault<Cat>() .BindConstructorArg<string>().ToValue("Kitty"); var josephine = ctx.RegisterUniquelyNamed<PersonWithCat>() .UseConstructor((string name, Cat cat) => new PersonWithCat(name, cat)) .BindConstructorArg().ToValue("Josephine") .BindConstructorArg().ToRegisteredDefault() .GetReference(); ctx.RegisterDefault<PersonWithCat>() .UseConstructor((string name, Cat cat) => new PersonWithCat(name, cat)) .BindConstructorArg().ToValue("Josh") .BindConstructorArg().ToObjectProperty(josephine, j => j.Cat) // <-- refers to Josephine's cat .GetReference(); Continue reading: 16. Collection injection |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |