当前位置: 首页>>代码示例>>C#>>正文


C# ChannelDispatcher.SetEndpointAddressTable方法代码示例

本文整理汇总了C#中System.ServiceModel.Dispatcher.ChannelDispatcher.SetEndpointAddressTable方法的典型用法代码示例。如果您正苦于以下问题:C# ChannelDispatcher.SetEndpointAddressTable方法的具体用法?C# ChannelDispatcher.SetEndpointAddressTable怎么用?C# ChannelDispatcher.SetEndpointAddressTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Dispatcher.ChannelDispatcher的用法示例。


在下文中一共展示了ChannelDispatcher.SetEndpointAddressTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeServiceHost


//.........这里部分代码省略.........
                    ServiceEndpoint endpoint = stuff.Value.Endpoints[i];
                    string viaString = listenUri.AbsoluteUri;

                    // ensure all endpoints with this ListenUriInfo have same binding
                    if (endpoint.Binding != binding)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ABindingInstanceHasAlreadyBeenAssociatedTo1, viaString)));
                    }

                    // ensure all endpoints with this ListenUriInfo have same identity
                    if (!object.Equals(endpoint.Address.Identity, identity))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                      SR.GetString(SR.SFxWhenMultipleEndpointsShareAListenUriTheyMustHaveSameIdentity, viaString)));
                    }

                    // add binding parameters (endpoint scope and below)
                    AddMsmqIntegrationContractInformation(endpoint);
                    SecurityContractInformationEndpointBehavior.ServerInstance.AddBindingParameters(endpoint, parameters);
                    AddBindingParameters(endpoint, parameters);
                }

                // build IChannelListener and ChannelDispatcher
                IChannelListener listener;
                Type channelType = this.BuildChannelListener(stuff.Value,
                                                             serviceHost,
                                                             listenUri,
                                                             listenUriMode,
                                                             supportContextSession,
                                                             out listener);

                XmlQualifiedName bindingQname = new XmlQualifiedName(binding.Name, binding.Namespace);
                ChannelDispatcher channelDispatcher = new ChannelDispatcher(listener, bindingQname.ToString(), binding);
                channelDispatcher.SetEndpointAddressTable(endpointAddressTable);
                stuff.Value.ChannelDispatcher = channelDispatcher;

                bool canReceiveInTransaction = false;   // at least one operation is TransactionScopeRequired
                int transactedBatchSize = int.MaxValue;

                for (int i = 0; i < stuff.Value.Endpoints.Count; i++)
                {
                    ServiceEndpoint endpoint = stuff.Value.Endpoints[i];
                    string viaString = listenUri.AbsoluteUri;

                    EndpointFilterProvider provider = new EndpointFilterProvider();
                    EndpointDispatcher dispatcher = DispatcherBuilder.BuildDispatcher(serviceHost, description, endpoint, endpoint.Contract, provider);

                    for (int j = 0; j < endpoint.Contract.Operations.Count; j++)
                    {
                        OperationDescription operation = endpoint.Contract.Operations[j];
                        OperationBehaviorAttribute operationBehavior = operation.Behaviors.Find<OperationBehaviorAttribute>();
                        if (null != operationBehavior && operationBehavior.TransactionScopeRequired)
                        {
                            canReceiveInTransaction = true;
                            break;
                        }
                    }

                    if (!endpointInfosPerEndpointAddress.ContainsKey(endpoint.Address))
                    {
                        endpointInfosPerEndpointAddress.Add(endpoint.Address, new Collection<EndpointInfo>());
                    }
                    endpointInfosPerEndpointAddress[endpoint.Address].Add(new EndpointInfo(endpoint, dispatcher, provider));

                    channelDispatcher.Endpoints.Add(dispatcher);
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:66,代码来源:DispatcherBuilder.cs

示例2: InitializeServiceHost

 public void InitializeServiceHost(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHost)
 {
     if ((serviceHost.ImplementedContracts != null) && (serviceHost.ImplementedContracts.Count > 0))
     {
         this.EnsureThereAreApplicationEndpoints(description);
     }
     this.ValidateDescription(description, serviceHost);
     AspNetEnvironment.Current.AddHostingBehavior(serviceHost, description);
     description.Behaviors.Find<ServiceBehaviorAttribute>();
     this.InitializeServicePerformanceCounters(serviceHost);
     Dictionary<ListenUriInfo, StuffPerListenUriInfo> dictionary = new Dictionary<ListenUriInfo, StuffPerListenUriInfo>();
     Dictionary<EndpointAddress, Collection<EndpointInfo>> endpointInfosPerEndpointAddress = new Dictionary<EndpointAddress, Collection<EndpointInfo>>();
     for (int i = 0; i < description.Endpoints.Count; i++)
     {
         bool flag = false;
         ServiceEndpoint endpoint = description.Endpoints[i];
         foreach (OperationDescription description2 in endpoint.Contract.Operations)
         {
             if (description2.Behaviors.Find<ReceiveContextEnabledAttribute>() != null)
             {
                 flag = true;
                 break;
             }
         }
         if (flag)
         {
             IReceiveContextSettings property = endpoint.Binding.GetProperty<IReceiveContextSettings>(new BindingParameterCollection());
             if (property == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxReceiveContextSettingsPropertyMissing", new object[] { endpoint.Contract.Name, typeof(ReceiveContextEnabledAttribute).Name, endpoint.Address.Uri.AbsoluteUri, typeof(IReceiveContextSettings).Name })));
             }
             property.Enabled = true;
         }
         ListenUriInfo key = new ListenUriInfo(this.EnsureListenUri(serviceHost, endpoint), endpoint.ListenUriMode);
         if (!dictionary.ContainsKey(key))
         {
             dictionary.Add(key, new StuffPerListenUriInfo());
         }
         dictionary[key].Endpoints.Add(endpoint);
     }
     foreach (KeyValuePair<ListenUriInfo, StuffPerListenUriInfo> pair in dictionary)
     {
         ThreadSafeMessageFilterTable<EndpointAddress> table;
         IChannelListener listener;
         Uri listenUri = pair.Key.ListenUri;
         ListenUriMode listenUriMode = pair.Key.ListenUriMode;
         BindingParameterCollection bindingParameters = pair.Value.Parameters;
         Binding timeouts = pair.Value.Endpoints[0].Binding;
         EndpointIdentity objB = pair.Value.Endpoints[0].Address.Identity;
         table = new ThreadSafeMessageFilterTable<EndpointAddress> {
             table
         };
         bool supportContextSession = false;
         foreach (IServiceBehavior behavior in description.Behaviors)
         {
             if (behavior is IContextSessionProvider)
             {
                 supportContextSession = true;
             }
             behavior.AddBindingParameters(description, serviceHost, pair.Value.Endpoints, bindingParameters);
         }
         for (int k = 0; k < pair.Value.Endpoints.Count; k++)
         {
             ServiceEndpoint endpoint2 = pair.Value.Endpoints[k];
             string absoluteUri = listenUri.AbsoluteUri;
             if (endpoint2.Binding != timeouts)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("ABindingInstanceHasAlreadyBeenAssociatedTo1", new object[] { absoluteUri })));
             }
             if (!object.Equals(endpoint2.Address.Identity, objB))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxWhenMultipleEndpointsShareAListenUriTheyMustHaveSameIdentity", new object[] { absoluteUri })));
             }
             AddMsmqIntegrationContractInformation(endpoint2);
             SecurityContractInformationEndpointBehavior.ServerInstance.AddBindingParameters(endpoint2, bindingParameters);
             AddBindingParameters(endpoint2, bindingParameters);
         }
         this.BuildChannelListener(pair.Value, serviceHost, listenUri, listenUriMode, supportContextSession, out listener);
         XmlQualifiedName name = new XmlQualifiedName(timeouts.Name, timeouts.Namespace);
         ChannelDispatcher item = new ChannelDispatcher(listener, name.ToString(), timeouts);
         item.SetEndpointAddressTable(table);
         pair.Value.ChannelDispatcher = item;
         bool flag3 = false;
         int num3 = 0x7fffffff;
         for (int m = 0; m < pair.Value.Endpoints.Count; m++)
         {
             ServiceEndpoint endpoint3 = pair.Value.Endpoints[m];
             string text1 = listenUri.AbsoluteUri;
             EndpointFilterProvider provider = new EndpointFilterProvider(new string[0]);
             EndpointDispatcher endpointDispatcher = BuildDispatcher(serviceHost, description, endpoint3, endpoint3.Contract, provider);
             for (int n = 0; n < endpoint3.Contract.Operations.Count; n++)
             {
                 OperationDescription description3 = endpoint3.Contract.Operations[n];
                 OperationBehaviorAttribute attribute = description3.Behaviors.Find<OperationBehaviorAttribute>();
                 if ((attribute != null) && attribute.TransactionScopeRequired)
                 {
                     flag3 = true;
                     break;
                 }
             }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:DispatcherBuilder.cs


注:本文中的System.ServiceModel.Dispatcher.ChannelDispatcher.SetEndpointAddressTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。