public SystemBuilder Use(ServiceUseOptions options) { if (options == null) { throw new ArgumentNullException("options"); } options.Validate(); var key = options.Key; var type = options.ServiceType; var policy = options.Policy; var registration = new ServiceRegistration(type, options.ImplementationType) { Instance = options.Instance, Scope = options.Scope, ServiceKey = key }; if (key != null) { if (policy == ServiceUsePolicy.Replace) { if (ServiceContainer.IsRegistered(type, key)) { ServiceContainer.Unregister(type, key); } } ServiceContainer.Register(registration); } else { if (policy == ServiceUsePolicy.Replace) { if (ServiceContainer.IsRegistered(type)) { ServiceContainer.Unregister(type); } } ServiceContainer.Register(registration); } return(this); }
public ServiceUseConfigurationProvider() { Options = new ServiceUseOptions(typeof(TService)); }
public ServiceUseWithBindingConfigurationProvider(ServiceUseOptions options) { this.options = options; }
ISystemBuilder ISystemBuilder.Use(ServiceUseOptions options) { return(Use(options)); }
public SystemBuilder Use(ServiceUseOptions options) { if (options == null) throw new ArgumentNullException("options"); options.Validate(); var key = options.Key; var type = options.ServiceType; var policy = options.Policy; var registration = new ServiceRegistration(type, options.ImplementationType) { Instance = options.Instance, Scope = options.Scope, ServiceKey = key }; if (key != null) { if (policy == ServiceUsePolicy.Replace) { if (ServiceContainer.IsRegistered(type, key)) ServiceContainer.Unregister(type, key); } ServiceContainer.Register(registration); } else { if (policy == ServiceUsePolicy.Replace) { if (ServiceContainer.IsRegistered(type)) ServiceContainer.Unregister(type); } ServiceContainer.Register(registration); } return this; }
ISystemBuilder ISystemBuilder.Use(ServiceUseOptions options) { return Use(options); }