public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {
            if (serviceDescription == null) {
                throw new ArgumentNullException("serviceDescription");
            }

            if (serviceHostBase == null) {
                throw new ArgumentNullException("serviceHostBase");
            }

            IEnumerable<string> source = serviceDescription.Endpoints.Where<ServiceEndpoint>(delegate(ServiceEndpoint ep) {
                return ep.Contract.ContractType.IsAssignableFrom(this._implementationType);
            }).Select<ServiceEndpoint, string>(delegate(ServiceEndpoint ep) {
                return ep.Contract.Name;
            });

            OrchardInstanceProvider provider = new OrchardInstanceProvider(this._workContextAccessor, this._componentRegistration);
            foreach (ChannelDispatcherBase base2 in serviceHostBase.ChannelDispatchers) {
                ChannelDispatcher dispatcher = base2 as ChannelDispatcher;
                if (dispatcher != null) {
                    foreach (EndpointDispatcher dispatcher2 in dispatcher.Endpoints) {
                        if (source.Contains<string>(dispatcher2.ContractName)) {
                            dispatcher2.DispatchRuntime.InstanceProvider = provider;
                        }
                    }
                    continue;
                }
            }
        }
Пример #2
0
        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            if (serviceDescription == null)
            {
                throw new ArgumentNullException("serviceDescription");
            }

            if (serviceHostBase == null)
            {
                throw new ArgumentNullException("serviceHostBase");
            }

            IEnumerable <string> source = serviceDescription.Endpoints.Where <ServiceEndpoint>(delegate(ServiceEndpoint ep) {
                return(ep.Contract.ContractType.IsAssignableFrom(this._implementationType));
            }).Select <ServiceEndpoint, string>(delegate(ServiceEndpoint ep) {
                return(ep.Contract.Name);
            });

            OrchardInstanceProvider provider = new OrchardInstanceProvider(this._workContextAccessor, this._componentRegistration);

            foreach (ChannelDispatcherBase base2 in serviceHostBase.ChannelDispatchers)
            {
                ChannelDispatcher dispatcher = base2 as ChannelDispatcher;
                if (dispatcher != null)
                {
                    foreach (EndpointDispatcher dispatcher2 in dispatcher.Endpoints)
                    {
                        if (source.Contains <string>(dispatcher2.ContractName))
                        {
                            dispatcher2.DispatchRuntime.InstanceProvider = provider;
                        }
                    }
                    continue;
                }
            }
        }