The static helper class Create defines methods for getting objects from the current container.


New<T>()
Gets an instance of type T from the current container, according to the nearest registration. The instance's lifespan is not tracked by the container so the caller is responsible for calling the IDisposable.Dispose() on the resulting instance if applicable.
New<T>(LifespanTracking tracking)
Gets an instance of type T from the current container, according to the nearest registration. This overload allows the caller to supply the LifespanTracking to be applied to the new instance, such as LifespanTracking.Automatic which indicates the container should cleanup the instance if it is an IDisposable .
NewCopy<T, TSource>(TSource source)
Same as New<T>() except that the new instance will be initialized with data copied from source ; effectively a copy-construction.
NewCopy<T, TSource>(TSource source, LifespanTracking tracking)
Same as New<T>(LifespanTracking tracking) except that the new instance will be initialized with data copied from source; effectively a copy-construction.
NewInit<T>()
Same as New<T>() except that the result is an Initializer<T> . The initializer has an Init<TInit>() method that may be used to initialize the new instance at a later time.
NewInit<T>(Func<IContainer, T, T>initialize)
Gets an instance of type T from the current container, according to the nearest registration and invokes the specified initialize function on the instance. The initialize function's result is returned to the caller.
NewNamed<T>(string name)
Gets a named instance of type T from the current container, according to the nearest registration. The instance's lifespan is not tracked by the container so the caller is responsible for calling the IDisposable.Dispose() on the resulting instance if applicable.
NewWithParams<T>(params Param[] parameters)
Gets an instance of type T from the current container, according to the nearest registration. The specified parameters are injected into the constructor of a new instance if the type's registration warrants construction. The instance's lifespan is not tracked by the container so the caller is responsible for calling the IDisposable.Dispose() on the resulting instance if applicable.

Last edited Sep 2, 2013 at 3:15 PM by cerebralkungfu, version 3

Comments

No comments yet.