Наследование: IWcfExtensionVisitor
        protected void ConfigureServiceHost(ServiceHost serviceHost, IWcfServiceModel serviceModel, ComponentModel model)
        {
            serviceHost.Description.Behaviors.Add(
                new WindsorDependencyInjectionServiceBehavior(kernel, model)
                );

            var burden    = new WcfBurden(kernel);
            var contracts = new HashSet <ContractDescription>();
            Dictionary <IWcfEndpoint, ServiceEndpoint> endpoints = null;

            if (serviceModel != null && serviceModel.Endpoints.Count > 0)
            {
                endpoints = new Dictionary <IWcfEndpoint, ServiceEndpoint>();
                var builder = new ServiceEndpointBuilder(this, serviceHost);

                foreach (var endpoint in serviceModel.Endpoints)
                {
                    endpoints.Add(endpoint, builder.AddServiceEndpoint(endpoint));
                }
            }

            var extensions = new ServiceHostExtensions(serviceHost, kernel)
                             .Install(burden, new WcfServiceExtensions());

            if (serviceModel != null)
            {
                extensions.Install(serviceModel.Extensions, burden);
            }

            extensions.Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Services));

            if (endpoints != null)
            {
                foreach (var endpoint in endpoints)
                {
                    var addContract = contracts.Add(endpoint.Value.Contract);
                    new ServiceEndpointExtensions(endpoint.Value, addContract, kernel)
                    .Install(endpoint.Key.Extensions, burden);
                }
            }

            if (serviceHost is IWcfServiceHost)
            {
                var wcfServiceHost = (IWcfServiceHost)serviceHost;

                wcfServiceHost.EndpointCreated += (_, e) =>
                {
                    var addContract        = contracts.Add(e.Endpoint.Contract);
                    var endpointExtensions = new ServiceEndpointExtensions(e.Endpoint, addContract, kernel)
                                             .Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Services));

                    if (serviceModel != null)
                    {
                        endpointExtensions.Install(serviceModel.Extensions, burden);
                    }
                };
            }

            serviceHost.Extensions.Add(new WcfBurdenExtension <ServiceHostBase>(burden));
        }
Пример #2
0
		protected void ConfigureChannelFactory(ChannelFactory channelFactory, IWcfClientModel clientModel,
											   IWcfBurden burden)
		{
			BindChannelFactoryAware(channelFactory, kernel, burden);

			var extensions =new ServiceEndpointExtensions(channelFactory.Endpoint, kernel)
				.Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Clients));

			if (clientModel != null)
			{
				extensions.Install(clientModel.Extensions, burden);
				extensions.Install(clientModel.Endpoint.Extensions, burden);
			}
		}
		protected void ConfigureChannelFactory(ChannelFactory channelFactory, IWcfClientModel clientModel, IWcfBurden burden)
		{
			var extensions = new ChannelFactoryExtensions(channelFactory, Kernel)
				.Install(burden, new WcfChannelExtensions());

			var endpointExtensions = new ServiceEndpointExtensions(channelFactory.Endpoint, true, Kernel)
				.Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Clients));

			if (clientModel != null)
			{
				extensions.Install(clientModel.Extensions, burden);
				endpointExtensions.Install(clientModel.Extensions, burden);
				endpointExtensions.Install(clientModel.Endpoint.Extensions, burden);
			}

			burden.Add(new ChannelFactoryHolder(channelFactory));
		}
Пример #4
0
        protected void ConfigureChannelFactory(ChannelFactory channelFactory, IWcfClientModel clientModel, IWcfBurden burden)
        {
            var extensions = new ChannelFactoryExtensions(channelFactory, Kernel)
                             .Install(burden, new WcfChannelExtensions());

            var endpointExtensions = new ServiceEndpointExtensions(channelFactory.Endpoint, true, Kernel)
                                     .Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Clients));

            if (clientModel != null)
            {
                extensions.Install(clientModel.Extensions, burden);
                endpointExtensions.Install(clientModel.Extensions, burden);
                endpointExtensions.Install(clientModel.Endpoint.Extensions, burden);
            }

            burden.Add(new ChannelFactoryHolder(channelFactory));
        }
		protected void ConfigureServiceHost(ServiceHost serviceHost, IWcfServiceModel serviceModel, ComponentModel model)
		{
			serviceHost.Description.Behaviors.Add(
				new WindsorDependencyInjectionServiceBehavior(kernel, model)
				);

			var burden = new WcfBurden(kernel);
			var contracts = new HashSet<ContractDescription>();
			Dictionary<IWcfEndpoint, ServiceEndpoint> endpoints = null;

			if (serviceModel != null && serviceModel.Endpoints.Count > 0)
			{
				endpoints = new Dictionary<IWcfEndpoint, ServiceEndpoint>();
				var builder = new ServiceEndpointBuilder(this, serviceHost);

				foreach (var endpoint in serviceModel.Endpoints)
				{
					endpoints.Add(endpoint, builder.AddServiceEndpoint(endpoint));
				}
			}

			var extensions = new ServiceHostExtensions(serviceHost, kernel)
				.Install(burden, new WcfServiceExtensions());

			if (serviceModel != null)
			{
				extensions.Install(serviceModel.Extensions, burden);
			}

			extensions.Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Services));

			if (endpoints != null)
			{
				foreach (var endpoint in endpoints)
				{
					var addContract = contracts.Add(endpoint.Value.Contract);
					new ServiceEndpointExtensions(endpoint.Value, addContract, kernel)
						.Install(endpoint.Key.Extensions, burden);
				}
			}

			if (serviceHost is IWcfServiceHost)
			{
				var wcfServiceHost = (IWcfServiceHost)serviceHost;

				wcfServiceHost.EndpointCreated += (_, e) =>
				{
					var addContract = contracts.Add(e.Endpoint.Contract);
					var endpointExtensions = new ServiceEndpointExtensions(e.Endpoint, addContract, kernel)
						.Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Services));

					if (serviceModel != null)
					{
						endpointExtensions.Install(serviceModel.Extensions, burden);
					}
				};
			}

			serviceHost.Extensions.Add(new WcfBurdenExtension<ServiceHostBase>(burden));
		}