/// <summary> /// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects. /// </summary> /// <param name="serviceDescription">The service description.</param> /// <param name="serviceHostBase">The host that is currently being built.</param> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="serviceDescription" /> or /// <paramref name="serviceHostBase" /> is <see langword="null" />. /// </exception> public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceDescription == null) { throw new ArgumentNullException("serviceDescription"); } if (serviceHostBase == null) { throw new ArgumentNullException("serviceHostBase"); } var implementedContracts = (from ep in serviceDescription.Endpoints where ep.Contract.ContractType.IsAssignableFrom(_serviceData.ServiceTypeToHost) select ep.Contract.Name).ToArray(); var instanceProvider = new AutofacInstanceProvider(_rootLifetimeScope, _serviceData); var endpointDispatchers = from cd in serviceHostBase.ChannelDispatchers.OfType <ChannelDispatcher>() from ed in cd.Endpoints where implementedContracts.Contains(ed.ContractName) select ed; foreach (var ed in endpointDispatchers) { ed.DispatchRuntime.InstanceProvider = instanceProvider; } }
public void ReleaseInstance_NullInstanceContext() { var data = new ServiceImplementationData(); var container = new ContainerBuilder().Build(); var provider = new AutofacInstanceProvider(container, data); object instance = new object(); Assert.Throws<ArgumentNullException>(() => provider.ReleaseInstance(null, instance)); }
public void GetInstance_NullInstanceContext() { var data = new ServiceImplementationData(); var container = new ContainerBuilder().Build(); var provider = new AutofacInstanceProvider(container, data); var message = new TestMessage(); Assert.Throws<ArgumentNullException>(() => provider.GetInstance(null, message)); }
/// <summary> /// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects. /// </summary> /// <param name="serviceDescription">The service description.</param> /// <param name="serviceHostBase">The host that is currently being built.</param> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="serviceDescription" /> or /// <paramref name="serviceHostBase" /> is <see langword="null" />. /// </exception> public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceDescription == null) { throw new ArgumentNullException("serviceDescription"); } if (serviceHostBase == null) { throw new ArgumentNullException("serviceHostBase"); } var implementedContracts = (from ep in serviceDescription.Endpoints where ep.Contract.ContractType.IsAssignableFrom(_serviceData.ServiceTypeToHost) select ep.Contract.Name).ToArray(); var instanceProvider = new AutofacInstanceProvider(_rootLifetimeScope, _serviceData); var endpointDispatchers = from cd in serviceHostBase.ChannelDispatchers.OfType<ChannelDispatcher>() from ed in cd.Endpoints where implementedContracts.Contains(ed.ContractName) select ed; foreach (var ed in endpointDispatchers) { ed.DispatchRuntime.InstanceProvider = instanceProvider; } }