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));
        }
		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));
		}
Exemplo n.º 3
0
        internal static ServiceHost CreateServiceHostInternal <M>(IKernel kernel, IWcfServiceModel serviceModel, ComponentModel model, params Uri[] baseAddresses)
            where M : IWcfServiceModel
        {
            var serviceHostBuilder = kernel.Resolve <IServiceHostBuilder <M> >();

            return(serviceHostBuilder.Build(model, (M)serviceModel, baseAddresses));
        }
Exemplo n.º 4
0
        public WcfSourceRegion(IWcfServiceModel model, ModelItem modelItem)
        {
            LabelWidth        = 46;
            ToolRegionName    = "WcfSourceRegion";
            Dependants        = new List <IToolRegion>();
            NewSourceCommand  = new Microsoft.Practices.Prism.Commands.DelegateCommand(model.CreateNewSource);
            EditSourceCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(() => model.EditSource(SelectedSource), CanEditSource);
            var sources = model.RetrieveSources().OrderBy(source => source.Name);

            Sources            = sources.ToObservableCollection();
            IsEnabled          = true;
            _modelItem         = modelItem;
            SourceId           = modelItem.GetProperty <Guid>("SourceId");
            SourcesHelpText    = Warewolf.Studio.Resources.Languages.HelpText.WcfServiceSourcesHelp;
            EditSourceHelpText = Warewolf.Studio.Resources.Languages.HelpText.WcfServiceEditSourceHelp;
            NewSourceHelpText  = Warewolf.Studio.Resources.Languages.HelpText.WcfServiceNewSourceHelp;

            SourcesTooltip    = Warewolf.Studio.Resources.Languages.Tooltips.ManageWcfServiceSourcesTooltip;
            EditSourceTooltip = Warewolf.Studio.Resources.Languages.Tooltips.ManageWcfServiceEditSourceTooltip;
            NewSourceTooltip  = Warewolf.Studio.Resources.Languages.Tooltips.ManageWcfServiceNewSourceTooltip;

            if (SourceId != Guid.Empty)
            {
                SelectedSource = Sources.FirstOrDefault(source => source.Id == SourceId);
            }
        }
Exemplo n.º 5
0
        private void CreateAndOpenServiceHost(IWcfServiceModel serviceModel, ComponentModel model)
        {
            var serviceHost = CreateServiceHost(kernel, serviceModel, model);

            lock (sync)
            {
                hosts.Add(serviceHost);
            }
            serviceHost.Open();
        }
Exemplo n.º 6
0
        public static ServiceHost CreateServiceHost(IKernel Kernel, IWcfServiceModel serviceModel, ComponentModel model, params Uri[] baseAddresses)
        {
            var createServiceHost = createServiceHostCache.GetOrAdd(serviceModel.GetType(), serviceModelType =>
            {
                return((CreateServiceHostDelegate)Delegate.CreateDelegate(typeof(CreateServiceHostDelegate),
                                                                          createServiceHostMethod.MakeGenericMethod(serviceModelType)));
            });

            return(createServiceHost(Kernel, serviceModel, model, baseAddresses));
        }
        protected static Uri[] GetEffectiveBaseAddresses(IWcfServiceModel serviceModel, Uri[] defaultBaseAddresses)
        {
            var baseAddresses = new List <Uri>(serviceModel.BaseAddresses);

            foreach (Uri defaultBaseAddress in defaultBaseAddresses)
            {
                if (baseAddresses.Exists(uri => uri.Scheme == defaultBaseAddress.Scheme) == false)
                {
                    baseAddresses.Add(defaultBaseAddress);
                }
            }
            return(baseAddresses.ToArray());
        }
Exemplo n.º 8
0
 public ManageWcfServiceInputViewModel(IWcfEndPointViewModel model, IWcfServiceModel serviceModel)
 {
     PasteResponseAvailable = false;
     PasteResponseVisible   = false;
     IsTesting           = false;
     CloseCommand        = new DelegateCommand(ExecuteClose);
     OkCommand           = new DelegateCommand(ExecuteOk);
     TestCommand         = new DelegateCommand(ExecuteTest);
     _generateOutputArea = new GenerateOutputsRegion();
     _generateInputArea  = new GenerateInputsRegion();
     Errors        = new List <string>();
     _viewmodel    = model;
     _serviceModel = serviceModel;
 }
Exemplo n.º 9
0
        private void CreateAndOpenServiceHost(IWcfServiceModel serviceModel, ComponentModel model)
        {
            var serviceHost  = CreateServiceHost(kernel, serviceModel, model);
            var serviceHosts = model.ExtendedProperties[WcfConstants.ServiceHostsKey] as IList <ServiceHost>;

            if (serviceHosts == null)
            {
                serviceHosts = new List <ServiceHost>();
                model.ExtendedProperties[WcfConstants.ServiceHostsKey] = serviceHosts;
            }

            serviceHosts.Add(serviceHost);

            serviceHost.Open();
        }
Exemplo n.º 10
0
        private static IWcfServiceModel SelectBestHostedServiceModel(ComponentModel model)
        {
            IWcfServiceModel serviceModel = null;

            foreach (var candidateServiceModel in WcfUtils.FindDependencies <IWcfServiceModel>(model.CustomDependencies, WcfUtils.IsHosted))
            {
                if (candidateServiceModel is M)
                {
                    serviceModel = candidateServiceModel;
                    break;
                }
                else
                {
                    serviceModel = serviceModel ?? candidateServiceModel;
                }
            }

            return(serviceModel);
        }
Exemplo n.º 11
0
        public WcfActionRegion(IWcfServiceModel model, ModelItem modelItem, ISourceToolRegion <IWcfServerSource> source)
        {
            try
            {
                Errors = new List <string>();

                LabelWidth                = 46;
                ToolRegionName            = "DbActionRegion";
                _modelItem                = modelItem;
                _model                    = model;
                _source                   = source;
                _source.SomethingChanged += SourceOnSomethingChanged;
                Dependants                = new List <IToolRegion>();
                IsRefreshing              = false;
                if (_source.SelectedSource != null)
                {
                    Actions = model.GetActions(_source.SelectedSource);
                }
                if (!string.IsNullOrEmpty(Method.FullName))
                {
                    IsActionEnabled = true;
                    SelectedAction  = Actions.FirstOrDefault(action => action.FullName == Method.FullName);
                }
                RefreshActionsCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(() =>
                {
                    IsRefreshing = true;
                    if (_source.SelectedSource != null)
                    {
                        Actions = model.GetActions(_source.SelectedSource);
                    }
                    IsRefreshing = false;
                }, CanRefresh);

                IsEnabled  = true;
                _modelItem = modelItem;
            }
            catch (Exception e)
            {
                Errors.Add(e.Message);
            }
        }
Exemplo n.º 12
0
 private void CreateServiceHostWhenHandlerIsValid(IHandler handler, IWcfServiceModel serviceModel, ComponentModel model)
 {
     if (serviceModel.ShouldOpenEagerly.GetValueOrDefault(OpenServiceHostsEagerly) || handler.CurrentState == HandlerState.Valid)
     {
         CreateAndOpenServiceHost(serviceModel, model);
     }
     else
     {
         HandlersChangedDelegate onStateChanged = null;
         onStateChanged = (ref bool stateChanged) =>
         {
             if (handler.CurrentState == HandlerState.Valid && onStateChanged != null)
             {
                 kernel.HandlersChanged -= onStateChanged;
                 onStateChanged          = null;
                 CreateAndOpenServiceHost(serviceModel, model);
             }
         };
         kernel.HandlersChanged += onStateChanged;
     }
 }
		protected static Uri[] GetEffectiveBaseAddresses(IWcfServiceModel serviceModel, Uri[] defaultBaseAddresses)
		{
			var baseAddresses = new List<Uri>(serviceModel.BaseAddresses);
			foreach (Uri defaultBaseAddress in defaultBaseAddresses)
			{
				if (baseAddresses.Exists(uri => uri.Scheme == defaultBaseAddress.Scheme) == false)
				{
					baseAddresses.Add(defaultBaseAddress);
				}
			}
			return baseAddresses.ToArray();
		}
Exemplo n.º 14
0
 public static bool IsHosted(IWcfServiceModel serviceModel)
 {
     return(serviceModel.IsHosted);
 }
Exemplo n.º 15
0
		protected Uri[] GetEffectiveBaseAddresses(IWcfServiceModel serviceModel, Uri[] defaultBaseAddresses)
		{
			var baseAddresses = new List<Uri>(serviceModel.BaseAddresses);
			foreach (Uri defaultBaseAddress in defaultBaseAddresses)
			{
				if (!baseAddresses.Exists(delegate(Uri uri)
				{
					return uri.Scheme == defaultBaseAddress.Scheme;
				}))
				{
					baseAddresses.Add(defaultBaseAddress);
				}
			}
			return baseAddresses.ToArray();
		}
Exemplo n.º 16
0
 public WcfEndPointViewModel(ModelItem modelItem, IWcfServiceModel model)
     : base(modelItem)
 {
     Model = model;
     SetupCommonProperties();
 }