• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Dispatcher.ChannelDispatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ChannelDispatcher类属于System.ServiceModel.Dispatcher命名空间,在下文中一共展示了ChannelDispatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ListenerHandler

        internal ListenerHandler(IListenerBinder listenerBinder, ChannelDispatcher channelDispatcher, ServiceHostBase host, ServiceThrottle throttle, IDefaultCommunicationTimeouts timeouts)
        {
            this.listenerBinder = listenerBinder;
            if (!((this.listenerBinder != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.listenerBinder != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
            }

            this.channelDispatcher = channelDispatcher;
            if (!((this.channelDispatcher != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.channelDispatcher != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
            }

            this.host = host;
            if (!((this.host != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.host != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("host");
            }

            this.throttle = throttle;
            if (!((this.throttle != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.throttle != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("throttle");
            }

            this.timeouts = timeouts;

            this.endpoints = channelDispatcher.EndpointDispatcherTable;
            this.acceptor = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:35,代码来源:ListenerHandler.cs


示例2: Handle

        public bool Handle(Exception exception, ChannelDispatcher dispatcher, WCFServiceController wcfServiceController)
        {
            if (this.pendingRestart)
            {
                return false;
            }

            if (!(exception is CommunicationException))
            {
                AcceptedErrorLimitation.Add(exception);
                if (AcceptedErrorLimitation.ExceedLimit())
                {
                    AutoRestartLimitation.Add(exception);
                    if (AutoRestartLimitation.ExceedLimit())
                    {
                        _logger.LogWarning("Unable solve exception with configured max-times of WCF Service restart." +
                                           string.Format(
                                               "WCF Servuce {0}, Times of Auto-Restart has exceed the max value within configued time range, waiting window service restart",
                                               wcfServiceController.ServiceName));
                        this.pendingRestart = true;
                        return false;
                    }
                    else
                    {
                        AcceptedErrorLimitation.ResetCount();
                        return Handle(wcfServiceController);
                    }
                }
            }

            return true;
        }
开发者ID:philfanzhou,项目名称:PredictFuture,代码行数:32,代码来源:AutoRestartHandler.cs


示例3: CreateHttpGetChannelDispatcher

        private static void CreateHttpGetChannelDispatcher(ServiceHostBase host, Uri listenUri, MetadataSet metadata)
        {
            //创建Binding
            TextMessageEncodingBindingElement messageEncodingElement = new TextMessageEncodingBindingElement() { MessageVersion = MessageVersion.None };
            HttpTransportBindingElement transportElement = new HttpTransportBindingElement();
            Utility.SetPropertyValue(transportElement, "Method", "GET");
            Binding binding = new CustomBinding(messageEncodingElement, transportElement);

            //创建ChannelListener
            IChannelListener listener = binding.BuildChannelListener<IReplyChannel>(listenUri, string.Empty, ListenUriMode.Explicit, new BindingParameterCollection());
            ChannelDispatcher dispatcher = new ChannelDispatcher(listener, "ServiceMetadataBehaviorHttpGetBinding", binding) { MessageVersion = binding.MessageVersion };

            //创建EndpointDispatcher
            EndpointDispatcher endpoint = new EndpointDispatcher(new EndpointAddress(listenUri), "IHttpGetMetadata", "http://www.artech.com/");

            //创建DispatchOperation,并设置DispatchMessageFormatter和OperationInvoker
            DispatchOperation operation = new DispatchOperation(endpoint.DispatchRuntime, "Get", "*", "*");
            operation.Formatter = Utility.CreateInstance<IDispatchMessageFormatter>(MessageOperationFormatterType, Type.EmptyTypes, new object[0]);
            MethodInfo method = typeof(IHttpGetMetadata).GetMethod("Get");
            operation.Invoker = Utility.CreateInstance<IOperationInvoker>(SyncMethodInvokerType, new Type[] { typeof(MethodInfo) }, new object[] { method });
            endpoint.DispatchRuntime.Operations.Add(operation);

            //设置SingletonInstanceContext和InstanceContextProvider
            MetadataProvisionService serviceInstance = new MetadataProvisionService(metadata);
            endpoint.DispatchRuntime.SingletonInstanceContext = new InstanceContext(host, serviceInstance);
            endpoint.DispatchRuntime.InstanceContextProvider = Utility.CreateInstance<IInstanceContextProvider>(SingletonInstanceContextProviderType, new Type[] { typeof(DispatchRuntime) }, new object[] { endpoint.DispatchRuntime });
            dispatcher.Endpoints.Add(endpoint);

            //设置ContractFilter和AddressFilter
            endpoint.ContractFilter = new MatchAllMessageFilter();
            endpoint.AddressFilter = new MatchAllMessageFilter();

            host.ChannelDispatchers.Add(dispatcher);
        }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:34,代码来源:ServiceMetadataBehaviorAttribute.cs


示例4: UnregisterListenerCommon

		protected void UnregisterListenerCommon (ChannelDispatcher channel, TimeSpan timeout)
		{
			var entry = Entries.First (e => e.ChannelDispatcher == channel);
			Entries.Remove (entry);

			entry.WaitHandle.Set (); // make sure to finish pending requests.
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:HttpListenerManager.cs


示例5: HttpChannelListenerEntry

		public HttpChannelListenerEntry (ChannelDispatcher channel, EventWaitHandle waitHandle)
		{
			ChannelDispatcher = channel;
			WaitHandle = waitHandle;
			ContextQueue = new Queue<HttpContextInfo> ();
			RetrieverLock = new object ();
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:HttpChannelListenerEntry.cs


示例6: IsConcurrent

        internal static bool IsConcurrent(ChannelDispatcher runtime, bool hasSession)
        {
            bool isConcurrencyModeSingle = true;

            if (ConcurrencyBehavior.SupportsTransactedBatch(runtime))
            {
                return false;
            }

            foreach (EndpointDispatcher endpointDispatcher in runtime.Endpoints)
            {
                if (endpointDispatcher.DispatchRuntime.EnsureOrderedDispatch)
                {
                    return false;
                }

                if (endpointDispatcher.DispatchRuntime.ConcurrencyMode != ConcurrencyMode.Single)
                {
                    isConcurrencyModeSingle = false;
                }
            }

            if (!isConcurrencyModeSingle)
            {
                return true;
            }

            if (!hasSession)
            {
                return true;
            }

            return false;
        }
开发者ID:shijiaxing,项目名称:wcf,代码行数:34,代码来源:ConcurrencyBehavior.cs


示例7: ErrorBehavior

 internal ErrorBehavior(ChannelDispatcher channelDispatcher)
 {
     this.handlers = EmptyArray<IErrorHandler>.ToArray(channelDispatcher.ErrorHandlers);
     this.debug = channelDispatcher.IncludeExceptionDetailInFaults;
     this.isOnServer = channelDispatcher.IsOnServer;
     this.messageVersion = channelDispatcher.MessageVersion;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:ErrorBehavior.cs


示例8: SetIsolationLevel

 private void SetIsolationLevel(ChannelDispatcher channelDispatcher)
 {
     if (channelDispatcher == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
     }
     channelDispatcher.TransactionIsolationLevel = this.transactionIsolationLevel;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:CallbackBehaviorAttribute.cs


示例9: RegisterListenerCommon

		protected void RegisterListenerCommon (ChannelDispatcher channel, TimeSpan timeout)
		{
			lock (entries_lock) {
				Entries.Add (new HttpChannelListenerEntry (channel, new AutoResetEvent (false)));

				Entries.Sort (HttpChannelListenerEntry.CompareEntries);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:HttpListenerManager.cs


示例10: ApplyDispatchBehaviorAddsTheProvider

 public void ApplyDispatchBehaviorAddsTheProvider()
 {
     // TODO: Figure out how to mock up the service host with endpoint dispatchers
     var listenerMock = new Mock<IChannelListener>();
     var channelDispatcher = new ChannelDispatcher(listenerMock.Object);
     var hostMock = new Mock<ServiceHostBase>();
     hostMock.Object.ChannelDispatchers.Add(channelDispatcher);
     var provider = new WcfChannelInstanceProvider(null);
     provider.ApplyDispatchBehavior(null, hostMock.Object);
 }
开发者ID:BiYiTuan,项目名称:CruiseControl.NET,代码行数:10,代码来源:WcfChannelInstanceProviderTests.cs


示例11: ApplyDispatchBehavior

        private static void ApplyDispatchBehavior(ChannelDispatcher dispatcher)
        {
            // Don't add an error handler if it already exists
            foreach (IErrorHandler errorHandler in dispatcher.ErrorHandlers)
            {
                if (errorHandler is ExceptionConverterErrorHandler) return;
            }

            dispatcher.ErrorHandlers.Add(new ExceptionConverterErrorHandler());
        }
开发者ID:liquidsnk,项目名称:Aspid,代码行数:10,代码来源:ExceptionConverterAttribute.cs


示例12: AssociateEndpointToDispatcher

 // This is a workaround to the fact that the id of the dispatcher and endpoint must match
 // for the endpoint to be exposed in the service metadata. For simply using the service,
 // this step is not necessary.
 private void AssociateEndpointToDispatcher(ServiceEndpoint endpoint, ChannelDispatcher dispatcher)
 {
     BindingFlags instanceBindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
     PropertyInfo endpointIdProperty = typeof(ServiceEndpoint).GetProperty("Id", instanceBindingFlags);
     PropertyInfo endpointDispatcherIdProperty = typeof(EndpointDispatcher).GetProperty("Id", instanceBindingFlags);
     string endpointId = endpointIdProperty.GetValue(endpoint, null) as string;
     foreach (EndpointDispatcher ed in dispatcher.Endpoints)
     {
         endpointDispatcherIdProperty.SetValue(ed, endpointId, null);
     }
 }
开发者ID:GusLab,项目名称:WCFSamples,代码行数:14,代码来源:PocoServiceBehavior.cs


示例13: SharedTransactedBatchContext

 internal SharedTransactedBatchContext(ChannelHandler handler, ChannelDispatcher dispatcher, int maxConcurrentBatches)
 {
     this.handler = handler;
     this.maxBatchSize = dispatcher.MaxTransactedBatchSize;
     this.maxConcurrentBatches = maxConcurrentBatches;
     this.currentBatchSize = dispatcher.MaxTransactedBatchSize;
     this.currentConcurrentBatches = 0;
     this.currentConcurrentDispatches = 0;
     this.successfullCommits = 0;
     this.isBatching = true;
     this.isolationLevel = dispatcher.TransactionIsolationLevel;
     this.txTimeout = TransactionBehavior.NormalizeTimeout(dispatcher.TransactionTimeout);
     this.BatchingStateChanged(this.isBatching);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:SharedTransactedBatchContext.cs


示例14: ApplyDispatchBehavior_Test

        public void ApplyDispatchBehavior_Test()
        {
            // Arrange
            ServiceHostBase host = new TestableServiceHostBase();
            Mock<IChannelListener> listener = new Mock<IChannelListener>();

            ChannelDispatcher dispatcher = new ChannelDispatcher(listener.Object);
            host.ChannelDispatchers.Add(dispatcher);

            ServiceHttpErrorBehaviorAttribute attribute = new ServiceHttpErrorBehaviorAttribute(typeof(HttpErrorHandler));

            // Act
            attribute.ApplyDispatchBehavior(null, host);

            // Assert
            Assert.IsType<HttpErrorHandler>(dispatcher.ErrorHandlers.First());
        }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:17,代码来源:ServiceHttpErrorBehaviorAttributeTest.cs


示例15: IsConcurrent

 internal static bool IsConcurrent(ChannelDispatcher runtime, bool hasSession)
 {
     if (!SupportsTransactedBatch(runtime))
     {
         if (!hasSession)
         {
             return true;
         }
         foreach (EndpointDispatcher dispatcher in runtime.Endpoints)
         {
             if (dispatcher.DispatchRuntime.ConcurrencyMode != ConcurrencyMode.Single)
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:ConcurrencyBehavior.cs


示例16: ApplyDispatchBehavior

		public void ApplyDispatchBehavior ()
		{
			var se = CreateEndpoint ();
			var od = se.Contract.Operations [0];
			// in .NET 3.5 it adds "OperationSelectorBehavior"
			int initCB = ContractDescription.GetContract (typeof (IMyService)).Behaviors.Count;
			// in .NET 3.5 it adds
			// - OperationInvokeBehavior, 
			// - OperationBehaviorAttribute, 
			// - DataContractSerializerOperationBehavior and 
			// - DataContractSerializerOperationGenerator
			int initOB = od.Behaviors.Count;
			// Assert.AreEqual (1, initCB, "#0-1");
			// Assert.AreEqual (4, initOB, "#0-2");

			var b = new WebHttpBehavior ();
			se.Behaviors.Add (b);
			var ed = new EndpointDispatcher (se.Address, se.Contract.Name, se.Contract.Namespace);
			IChannelListener l = new WebHttpBinding ().BuildChannelListener<IReplyChannel> (new BindingParameterCollection ());
			var cd = new ChannelDispatcher (l);
			cd.Endpoints.Add (ed); // without it this test results in NRE (it blindly adds IErrorHandler).
			Assert.AreEqual (0, cd.ErrorHandlers.Count, "#1-1");
			Assert.IsNull (ed.DispatchRuntime.OperationSelector, "#1-2");
			Assert.AreEqual (1, se.Behaviors.Count, "#1-3-1");
			Assert.AreEqual (initCB, se.Contract.Behaviors.Count, "#1-3-2");
			Assert.AreEqual (initOB, od.Behaviors.Count, "#1-3-3");

			Assert.IsTrue (ed.AddressFilter is EndpointAddressMessageFilter, "#1-4");

			b.ApplyDispatchBehavior (se, ed);
			// FIXME: implement and enable it later
			//Assert.AreEqual (1, cd.ErrorHandlers.Count, "#2-1");
			Assert.AreEqual (typeof (WebHttpDispatchOperationSelector),
					 ed.DispatchRuntime.OperationSelector.GetType (), "#2-2");
			Assert.AreEqual (1, se.Behaviors.Count, "#3-1");
			Assert.AreEqual (initCB, se.Contract.Behaviors.Count, "#3-2");
			Assert.AreEqual (initOB, od.Behaviors.Count, "#3-3");
			// ... i.e. nothing is added.

			Assert.IsTrue (ed.AddressFilter is PrefixEndpointAddressMessageFilter, "#3-4");

			Assert.AreEqual (0, ed.DispatchRuntime.Operations.Count, "#4-0"); // hmm... really?
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:43,代码来源:WebHttpBehaviorTest.cs


示例17: ListenerHandler

        internal ListenerHandler(IListenerBinder listenerBinder, ChannelDispatcher channelDispatcher, IDefaultCommunicationTimeouts timeouts)
        {
            _listenerBinder = listenerBinder;
            if (!((_listenerBinder != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.listenerBinder != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
            }

            _channelDispatcher = channelDispatcher;
            if (!((_channelDispatcher != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.channelDispatcher != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
            }

            _timeouts = timeouts;

            _endpoints = channelDispatcher.EndpointDispatcherTable;
        }
开发者ID:weshaggard,项目名称:wcf,代码行数:20,代码来源:ListenerHandler.cs


示例18: BuildChannelDispatcher

		private ChannelDispatcher BuildChannelDispatcher(Uri listenUri, ServiceHostBase host)
		{
			BindingParameterCollection parameters = new BindingParameterCollection();
			VirtualPathExtension item = host.Extensions.Find<VirtualPathExtension>();
			if (item != null)
			{
				parameters.Add(item);
			}

			IChannelListener<IReplyChannel> listener = null;
			WebHttpBinding binding = new WebHttpBinding();
			if (binding.CanBuildChannelListener<IReplyChannel>(parameters))
			{
				listener = binding.BuildChannelListener<IReplyChannel>(listenUri, parameters);
			}

			ChannelDispatcher channelDispatcher = new ChannelDispatcher(listener)
			{
				MessageVersion = MessageVersion.None
			};

			return channelDispatcher;
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:23,代码来源:WfWebScriptBehavior.cs


示例19: UnregisterListener

		public override void UnregisterListener (ChannelDispatcher channel, TimeSpan timeout)
		{
			UnregisterListenerCommon (channel, timeout);
		}
开发者ID:carrie901,项目名称:mono,代码行数:4,代码来源:HttpListenerManager.cs


示例20: ApplyDispatchBehavior

 private void ApplyDispatchBehavior(ChannelDispatcher dispatcher)
 {
     //Nothing here
 }
开发者ID:borealwinter,项目名称:simpl,代码行数:4,代码来源:EnterpriseServiceBehavior.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Dispatcher.ClientOperation类代码示例发布时间:2022-05-26
下一篇:
C# Discovery.EndpointDiscoveryMetadata类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap