本文整理汇总了C#中System.ServiceModel.Dispatcher.EndpointDispatcher类的典型用法代码示例。如果您正苦于以下问题:C# EndpointDispatcher类的具体用法?C# EndpointDispatcher怎么用?C# EndpointDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EndpointDispatcher类属于System.ServiceModel.Dispatcher命名空间,在下文中一共展示了EndpointDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EndpointDispatcher
EndpointDispatcher(EndpointDispatcher baseEndpoint, IEnumerable<AddressHeader> headers)
{
EndpointAddressBuilder builder = new EndpointAddressBuilder(baseEndpoint.EndpointAddress);
foreach (AddressHeader h in headers)
{
builder.Headers.Add(h);
}
EndpointAddress address = builder.ToEndpointAddress();
this.addressFilter = new EndpointAddressMessageFilter(address);
// channelDispatcher is Attached
this.contractFilter = baseEndpoint.ContractFilter;
this.contractName = baseEndpoint.ContractName;
this.contractNamespace = baseEndpoint.ContractNamespace;
this.dispatchRuntime = baseEndpoint.DispatchRuntime;
// endpointFilter is lazy
this.filterPriority = baseEndpoint.FilterPriority + 1;
this.originalAddress = address;
if (PerformanceCounters.PerformanceCountersEnabled)
{
this.perfCounterId = baseEndpoint.perfCounterId;
this.perfCounterBaseId = baseEndpoint.perfCounterBaseId;
}
this.id = baseEndpoint.id;
}
示例2: AddEndpoint
public void AddEndpoint(EndpointDispatcher endpoint)
{
lock (this.ThisLock)
{
MessageFilter endpointFilter = endpoint.EndpointFilter;
int filterPriority = endpoint.FilterPriority;
if (this.filters == null)
{
if (this.cachedEndpoints == null)
{
this.cachedEndpoints = new List<EndpointDispatcher>(2);
}
if (this.cachedEndpoints.Count < 2)
{
this.cachedEndpoints.Add(endpoint);
}
else
{
this.filters = new MessageFilterTable<EndpointDispatcher>();
for (int i = 0; i < this.cachedEndpoints.Count; i++)
{
int priority = this.cachedEndpoints[i].FilterPriority;
MessageFilter filter = this.cachedEndpoints[i].EndpointFilter;
this.filters.Add(filter, this.cachedEndpoints[i], priority);
}
this.filters.Add(endpointFilter, endpoint, filterPriority);
this.cachedEndpoints = null;
}
}
else
{
this.filters.Add(endpointFilter, endpoint, filterPriority);
}
}
}
示例3: XsdValidationInspector
void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
WsdlExporter wsdlExporter = new WsdlExporter();
wsdlExporter.ExportEndpoint(endpoint);
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(
new XsdValidationInspector(wsdlExporter.GeneratedXmlSchemas));
}
示例4: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
foreach (var operation in endpoint.Contract.Operations)
{
DecorateFormatterBehavior(operation, endpointDispatcher.DispatchRuntime);
}
}
示例5: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint Endpoint, EndpointDispatcher EndpointDispatcher)
{
return;
//EndpointDispatcher.DispatchRuntime.MessageInspectors.Add (new HeaderInsertClientMessageInspector ());
//foreach (DispatchOperation op in EndpointDispatcher.DispatchRuntime.Operations)
// op.ParameterInspectors.Add (new HeaderInsertClientMessageInspector ());
}
示例6: 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);
}
示例7: ArgumentNullException
void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
{
if (endpointDispatcher == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("endpointDispatcher"));
endpointDispatcher.DispatchRuntime.ValidateMustUnderstand = this.ValidateMustUnderstand;
}
示例8: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
foreach (DispatchOperation operation in endpointDispatcher.DispatchRuntime.Operations)
{
operation.CallContextInitializers.Add(new UnitOfWorkCallContextInitializer());
}
}
示例9: ApplyDispatchBehavior
/// <summary>
/// This service modify or extend the service across an endpoint.
/// </summary>
/// <param name="endpoint">The endpoint that exposes the contract.</param>
/// <param name="endpointDispatcher">
/// The endpoint dispatcher to be
/// modified or extended.
/// </param>
public void ApplyDispatchBehavior(ServiceEndpoint endpoint,
EndpointDispatcher endpointDispatcher)
{
// add inspector which detects cross origin requests
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(
new MessageInspector(endpoint));
}
示例10: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
var protoBinding = endpoint.Binding as ProtoBufBinding;
if (protoBinding == null)
throw new ConfigurationException("The endpoint behaviour, ProtoBufBindingEndpointBehaviour, can only be applied to an endpoint which has ProtoBufBinding as its binding.");
foreach (var operation in endpointDispatcher.DispatchRuntime.Operations)
{
var compressionBehaviour = protoBinding.GetOperationCompressionBehaviour(operation.Name);
var contractInfo = ContractInfo.FromAction(operation.Action);
var serviceContract = TypeFinder.FindServiceContract(contractInfo.ServiceContractName);
var paramTypes = TypeFinder.GetContractParamTypes(serviceContract, contractInfo.OperationContractName,
contractInfo.Action, false);
var formatter = new ProtoBufDispatchFormatter(new List<TypeInfo>(paramTypes), contractInfo.Action,
compressionBehaviour);
operation.Formatter = formatter;
operation.DeserializeRequest = true;
operation.SerializeReply = true;
}
}
示例11: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
foreach (var item in endpointDispatcher.DispatchRuntime.Operations)
{
item.CallContextInitializers.Add(new CultureSettingCallContextInitializer());
}
}
示例12: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
foreach (var op in endpoint.Contract.Operations)
{
op.Behaviors.Add(this);
}
}
示例13: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
foreach (DispatchOperation operation in endpointDispatcher.DispatchRuntime.Operations)
{
operation.ParameterInspectors.Add(new ConsumerInspector());
}
}
示例14: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
foreach (var errorHandler in errorHandlers)
{
endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(errorHandler);
}
}
示例15: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
{
if (serviceEndpoint == null)
throw new ArgumentNullException("serviceEndpoint");
if (endpointDispatcher == null)
throw new ArgumentNullException("endpointDispatcher");
// Apply URI-based operation selector
Dictionary<string, string> operationNameDictionary = new Dictionary<string, string>();
foreach (OperationDescription operation in serviceEndpoint.Contract.Operations)
{
try
{
operationNameDictionary.Add(operation.Name.ToLower(), operation.Name);
}
catch (ArgumentException)
{
throw new Exception(String.Format("The specified contract cannot be used with case insensitive URI dispatch because there is more than one operation named {0}", operation.Name));
}
}
endpointDispatcher.AddressFilter = new PrefixEndpointAddressMessageFilter(serviceEndpoint.Address);
endpointDispatcher.ContractFilter = new MatchAllMessageFilter();
endpointDispatcher.DispatchRuntime.OperationSelector = new UriPathSuffixOperationSelector(serviceEndpoint.Address.Uri, operationNameDictionary);
}