本文整理汇总了C#中System.ServiceModel.Description.WsdlEndpointConversionContext.GetOperationBinding方法的典型用法代码示例。如果您正苦于以下问题:C# WsdlEndpointConversionContext.GetOperationBinding方法的具体用法?C# WsdlEndpointConversionContext.GetOperationBinding怎么用?C# WsdlEndpointConversionContext.GetOperationBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Description.WsdlEndpointConversionContext
的用法示例。
在下文中一共展示了WsdlEndpointConversionContext.GetOperationBinding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttachPolicy
internal void AttachPolicy(ServiceEndpoint endpoint, WsdlEndpointConversionContext endpointContext, PolicyConversionContext policyContext)
{
SortedList<string, string> policyKeys = new SortedList<string, string>();
NamingHelper.DoesNameExist policyKeyIsUnique
= delegate(string name, object nameCollection)
{
return policyKeys.ContainsKey(name);
};
string key, keyBase;
ICollection<XmlElement> assertions;
WsdlNS.ServiceDescription policyWsdl = endpointContext.WsdlBinding.ServiceDescription;
assertions = policyContext.GetBindingAssertions();
// Add [wsdl:Binding] level Policy
WsdlNS.Binding wsdlBinding = endpointContext.WsdlBinding;
if (assertions.Count > 0)
{
keyBase = CreateBindingPolicyKey(wsdlBinding);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlBinding);
}
foreach (OperationDescription operation in endpoint.Contract.Operations)
{
if (!WsdlExporter.OperationIsExportable(operation))
{
continue;
}
assertions = policyContext.GetOperationBindingAssertions(operation);
// Add [wsdl:Binding/wsdl:operation] policy
if (assertions.Count > 0)
{
WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation);
keyBase = CreateOperationBindingPolicyKey(wsdlOperationBinding);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlOperationBinding);
}
//
// Add [wsdl:Binding/wsdl:operation] child policy
//
foreach (MessageDescription message in operation.Messages)
{
assertions = policyContext.GetMessageBindingAssertions(message);
// Add [wsdl:Binding/wsdl:operation/wsdl:(input, output, message)] policy
if (assertions.Count > 0)
{
WsdlNS.MessageBinding wsdlMessageBinding = endpointContext.GetMessageBinding(message);
keyBase = CreateMessageBindingPolicyKey(wsdlMessageBinding, message.Direction);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlMessageBinding);
}
}
foreach (FaultDescription fault in operation.Faults)
{
assertions = policyContext.GetFaultBindingAssertions(fault);
// Add [wsdl:Binding/wsdl:operation/wsdl:fault] policy
if (assertions.Count > 0)
{
WsdlNS.FaultBinding wsdlFaultBinding = endpointContext.GetFaultBinding(fault);
keyBase = CreateFaultBindingPolicyKey(wsdlFaultBinding);
key = NamingHelper.GetUniqueName(keyBase, policyKeyIsUnique, null);
policyKeys.Add(key, key);
AttachItemPolicy(assertions, key, policyWsdl, wsdlFaultBinding);
}
}
}
}
示例2: AttachPolicy
internal void AttachPolicy(ServiceEndpoint endpoint, WsdlEndpointConversionContext endpointContext, PolicyConversionContext policyContext)
{
string str;
SortedList<string, string> policyKeys = new SortedList<string, string>();
NamingHelper.DoesNameExist doesNameExist = (name, nameCollection) => policyKeys.ContainsKey(name);
System.Web.Services.Description.ServiceDescription serviceDescription = endpointContext.WsdlBinding.ServiceDescription;
ICollection<XmlElement> bindingAssertions = policyContext.GetBindingAssertions();
System.Web.Services.Description.Binding wsdlBinding = endpointContext.WsdlBinding;
if (bindingAssertions.Count > 0)
{
str = NamingHelper.GetUniqueName(CreateBindingPolicyKey(wsdlBinding), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, wsdlBinding);
}
foreach (OperationDescription description2 in endpoint.Contract.Operations)
{
if (WsdlExporter.OperationIsExportable(description2))
{
bindingAssertions = policyContext.GetOperationBindingAssertions(description2);
if (bindingAssertions.Count > 0)
{
OperationBinding operationBinding = endpointContext.GetOperationBinding(description2);
str = NamingHelper.GetUniqueName(CreateOperationBindingPolicyKey(operationBinding), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, operationBinding);
}
foreach (MessageDescription description3 in description2.Messages)
{
bindingAssertions = policyContext.GetMessageBindingAssertions(description3);
if (bindingAssertions.Count > 0)
{
MessageBinding messageBinding = endpointContext.GetMessageBinding(description3);
str = NamingHelper.GetUniqueName(CreateMessageBindingPolicyKey(messageBinding, description3.Direction), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, messageBinding);
}
}
foreach (FaultDescription description4 in description2.Faults)
{
bindingAssertions = policyContext.GetFaultBindingAssertions(description4);
if (bindingAssertions.Count > 0)
{
FaultBinding faultBinding = endpointContext.GetFaultBinding(description4);
str = NamingHelper.GetUniqueName(CreateFaultBindingPolicyKey(faultBinding), doesNameExist, null);
policyKeys.Add(str, str);
this.AttachItemPolicy(bindingAssertions, str, serviceDescription, faultBinding);
}
}
}
}
}