本文整理汇总了C#中System.ServiceModel.Dispatcher.ChannelDispatcher类的典型用法代码示例。如果您正苦于以下问题:C# ChannelDispatcher类的具体用法?C# ChannelDispatcher怎么用?C# ChannelDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelDispatcher类属于System.ServiceModel.Dispatcher命名空间,在下文中一共展示了ChannelDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
示例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.
}
示例5: HttpChannelListenerEntry
public HttpChannelListenerEntry (ChannelDispatcher channel, EventWaitHandle waitHandle)
{
ChannelDispatcher = channel;
WaitHandle = waitHandle;
ContextQueue = new Queue<HttpContextInfo> ();
RetrieverLock = new object ();
}
示例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;
}
示例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;
}
示例8: SetIsolationLevel
private void SetIsolationLevel(ChannelDispatcher channelDispatcher)
{
if (channelDispatcher == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
}
channelDispatcher.TransactionIsolationLevel = this.transactionIsolationLevel;
}
示例9: RegisterListenerCommon
protected void RegisterListenerCommon (ChannelDispatcher channel, TimeSpan timeout)
{
lock (entries_lock) {
Entries.Add (new HttpChannelListenerEntry (channel, new AutoResetEvent (false)));
Entries.Sort (HttpChannelListenerEntry.CompareEntries);
}
}
示例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);
}
示例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());
}
示例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);
}
}
示例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());
}
示例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;
}