using System; using System.Collections.Generic; namespace MicroIoc { public interface IMicroIocContainer { /// /// Register a type within the container. Useful when registering a type by key, so calls to Resolve(null, key) will work /// /// The type of class being registered /// If specified, will associate a specific instance for this type /// Indicates if the registration should yield a singleton object when resolved /// The container, complete with new registration IMicroIocContainer Register(string key = null, bool isSingleton = false); /// /// Register an implementation type against an interface or class /// /// The type of interface or class to be registered /// The type of concrete class to be instantiated when is resolved from the container. /// If specified, will associate a specific instance for this type /// Indicates if the registration should yield a singleton object when resolved /// The container, complete with new registration IMicroIocContainer Register(string key = null, bool isSingleton = false) where TTo : TFrom; /// /// Register a specific instance of a concrete implementation for an interface or class /// /// The type of interface or class to be registered /// The instance to register in the container /// (Optional) a key to specify the instance within the container /// The container, complete with new registration IMicroIocContainer RegisterInstance(TInterface instance, string key = null); /// /// Register a specific instance of a concrete implementation for an interface or class /// /// The type of interface or class to be registered /// The instance to register in the container /// (Optional) a key to specify the instance within the container /// The container, complete with new registration IMicroIocContainer RegisterInstance(Type type, object instance, string key = null); /// /// Resolve an instance of the specified interface (or class) Type /// /// The type of interface or class to be resolved /// (Optional) a key to specify the instance within the container /// The registered instance if key is specified, or a dynamically instantiated instance, if not T Resolve(string key = null); /// /// Try to resolve an instance of the specified interface (or class) Type /// /// The type of interface or class to be resolved /// (Optional) a key to specify the instance within the container /// An instance of if registered, or null T TryResolve(string key = null) where T : class; /// /// Resolve an instance of the specified interface (or class) Type /// /// The type of interface or class to be resolved /// (Optional) a key to specify the instance within the container /// The registered instance if key is specified, or a dynamically instantiated instance, if not object Resolve(Type type, string key = null); /// /// Try to resolve an instance of the specified interface (or class) Type /// /// The type of interface or class to be resolved /// (Optional) a key to specify the instance within the container /// An instance of if registered, or null object TryResolve(Type type, string key = null); /// /// Resolve all registered instances of a specified type /// /// The type of interface or class to be resolved /// A collection of registered instances. If no instances are registered, returns empty collection, not null IEnumerable ResolveAll(); /// /// Resolve all registered instances of a specified type /// /// The type of interface or class to be resolved /// A collection of registered instances. If no instances are registered, returns empty collection, not null IEnumerable ResolveAll(Type type); /// /// /// /// IConfiguration GetConfiguration(); /// /// Create an instance with properties from the container. /// Only properties attributed [Inject] will be set. /// /// void BuildUp(object instance); } }