using System; namespace Wayne.Lib { /// /// This interface represents the locator part of the service container. Clients are often only interested in retrieving /// services from the container and thus only interested in this contract instead of the entire service container. /// public interface IServiceLocator { /// /// Retrieves the service of type serviceType from the container. /// /// Type of service. /// Service from the service container. TServiceContract GetService(); /// /// Retrieves the service of type serviceType from the container. /// /// Type of service. /// Id of the service , supplied upon registration. /// Service from the service container. TServiceContract GetService(string serviceId); /// /// Retrieves the service of type serviceType from the container. /// /// Type of service. /// Service from the service container. object GetService(Type serviceType); /// /// Retrieves the service of type serviceType from the container. /// /// Type of service. /// Id of the service , supplied upon registration. /// Service from the service container. object GetService(Type serviceType, string serviceId); /// /// Gets a registered service. If the service is not registered, it invokes the supplied /// callback to get a default instance of the service. NOTE that this instance is not automatically registered. /// /// /// /// TServiceContract GetServiceOrDefault(CreateDefaultService func); /// /// Gets a registered service. If the service is not registered, it invokes the supplied /// callback to get a default instance of the service. NOTE that this instance is not automatically registered. /// /// /// /// Id of the service , supplied upon registration. /// TServiceContract GetServiceOrDefault(CreateDefaultService func, string serviceId); /// /// Creates an instance of T. Service locator uses the first constructor it finds that it can use based on what is /// registered in the service container and the additional parameters. /// /// /// List of parameters that /// An instance of the created object [Obsolete("Use ServiceActivator.Create instead")] T CreateInstance(params object[] additionalParameter) where T : class; /// /// Creates an instance of T. Service locator uses the first constructor it finds that it can use based on what is /// registered in the service container and the additional parameters. /// /// /// Id of the service , supplied upon registration. /// List of parameters that /// An instance of the created object [Obsolete("Use ServiceActivator.Create instead")] T CreateInstance(string serviceId, params object[] additionalParameter) where T : class; /// /// Creates an instance of the specified type. Service locator uses the first constructor it finds that it can use /// based on what is regeistered in the service container and the additional parameters. /// /// /// /// object CreateInstance(Type typeToInstantiate, params object[] additionalParameter); /// /// Creates an instance of the specified type. Service locator uses the first constructor it finds that it can use /// based on what is regeistered in the service container and the additional parameters. /// /// /// Id of the service , supplied upon registration. /// /// object CreateInstance(Type typeToInstantiate, string serviceId, params object[] additionalParameter); /// /// Tries to locate the service T. If it does not succeed, it returns null. /// /// /// T TryGetService(); /// /// Tries to locate the service T. If it does not succeed, it returns null. /// /// /// Id of the service , supplied upon registration. /// T TryGetService(string serviceId); /// /// Tries to locate the specified service. If it does not succeed it returns null. /// /// /// object TryGetService(Type serviceType); /// /// Tries to locate the specified service. If it does not succeed it returns null. /// /// /// Id of the service , supplied upon registration. /// object TryGetService(Type serviceType, string serviceId); } /// /// Delegate for creating a default service with the IServiceLocator.GetServiceOrDefault method. /// /// /// public delegate T CreateDefaultService(); }