-
Notifications
You must be signed in to change notification settings - Fork 25
RegistrationOptions
- Registration Options
The Options enum is a flags enum, which can be used to modify certain registrations.
The enum provides the following members:
These members configure what a registration should be registered as.
Register this type as all interfaces it implements.
Registers this type as of its base classes except for `object
If this is registered as an instance of IFactory<T> or IAsyncFactory<T> either directly or as a result of using AsImplementedInterfaces) registers this as an instance of T as well.
Meant to be used in conjunction with UseAsFactory.
If this is registered as IFactory<T>, then we will apply the same options as are used for this to T.
This means that we are using AsImplementedInterfaces, and T implements an interface, we will register T as that interface.
Similarly if T is an IFactory<A> we will register it as a factory of A, and so on recursively.
Equivalent to AsImplementedInterfaces | AsBaseClasses
Equivalent to AsImplementedInterfaces | UseAsFactory
Equivalent to AsImplementedInterfaces | AsBaseClasses | UseAsFactory
These modify the scope of T for an IFactory<T>, and are meant to be used in conjunction with UseAsFactory.
If this is registered as IFactory<T>, then IFactory<T>.Create will be called once per resolution.
If this is registered as IFactory<T>, then IFactory<T>.Create will be called for every dependency.
If this is registered as IFactory<T>, then IFactory<T>.Create will only ever be called once, and T will be a singleton.
Don't apply decorators to any instances resolved using this registration
Options can be combined using the | operator, e.g. Options.UseAsFactory | Options.DoNotDecorate.
You can avoid repeating Options each time by adding using static StrongInject.Options; to the file, and then the above could be written as UseAsFactory | DoNotDecorate.