Offered by: Anton Cherkasov
§Services will be the basic foundations of the. NET design-time buildings. They aid to expose usage of specific features from exterior objects.
§Designers and components can acquire other companies through the use of providers. A. NET service provider is represented by the System. IServiceProvider interface. The interface provides a mechanism intended for retrieving a particular service object, given the kind of object to retrieve. Here is the only person in this interface:
object GetService(Type serviceType)
This technique, when overridden, will return an object that represents the required service type. If the company cannot go back an object of the specified type, then callers should anticipate the come back value to get null.
§A service textbox allows for solutions to be added and taken off to it. Therefore , exterior objects can have more control over what a company exposes. Something container is truly a service provider. The interface that represents a service container can be System. IServiceContainer, which is created from IServiceProvider, since shown:
general public interface IServiceContainer: IServiceProvider
IServiceContainer Interface Strategies
§Here would be the two strategies of this interface:
AddService: This process adds the specified service to the service container. This method has four overloads. void AddService(Type serviceType, thing service);
gap AddService(Type serviceType, ServiceCreatorCallback callback); void AddService(Type serviceType, target service, bool promote); emptiness AddService(Type serviceType, ServiceCreatorCallback callback, bool promote);
RemoveService: This approach removes the specified service in the service box. This method provides two overloads. void RemoveService(Type serviceType);
void RemoveService(Type serviceType, bool promote); �
§The. NET Framework has a class that is...