本文整理汇总了C#中System.ServiceModel.Description.PolicyConversionContext类的典型用法代码示例。如果您正苦于以下问题:C# PolicyConversionContext类的具体用法?C# PolicyConversionContext怎么用?C# PolicyConversionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolicyConversionContext类属于System.ServiceModel.Description命名空间,在下文中一共展示了PolicyConversionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrivacyNoticeBindingElement
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext)
{
if (policyContext == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policyContext");
XmlElement privacyNoticeAssertion = PolicyConversionContext.FindAssertion(policyContext.GetBindingAssertions(),
PrivacyNoticePolicyStrings.PrivacyNoticeName, PrivacyNoticePolicyStrings.PrivacyNoticeNamespace, true);
if (privacyNoticeAssertion != null)
{
PrivacyNoticeBindingElement settings =
policyContext.BindingElements.Find<PrivacyNoticeBindingElement>();
if (null == settings)
{
settings = new PrivacyNoticeBindingElement();
policyContext.BindingElements.Add(settings);
}
settings.Url = new Uri(privacyNoticeAssertion.InnerText);
string versionString = privacyNoticeAssertion.GetAttribute(PrivacyNoticePolicyStrings.PrivacyNoticeVersionAttributeName, PrivacyNoticePolicyStrings.PrivacyNoticeNamespace);
if (string.IsNullOrEmpty(versionString))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotImportPrivacyNoticeElementWithoutVersionAttribute)));
}
int version = 0;
if (!Int32.TryParse(versionString, out version))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.PrivacyNoticeElementVersionAttributeInvalid)));
}
settings.Version = version;
}
}
示例2: ArgumentNullException
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
if (importer == null)
{
throw new ArgumentNullException("importer");
}
if (context == null)
{
throw new ArgumentNullException("context");
}
UdpTransportBindingElement udpBindingElement = null;
bool multicast = false;
PolicyAssertionCollection policyAssertions = context.GetBindingAssertions();
if (policyAssertions.Remove(UdpPolicyStrings.TransportAssertion, UdpPolicyStrings.UdpNamespace) != null)
{
udpBindingElement = new UdpTransportBindingElement();
}
if (policyAssertions.Remove(UdpPolicyStrings.MulticastAssertion, UdpPolicyStrings.UdpNamespace) != null)
{
multicast = true;
}
if (udpBindingElement != null)
{
udpBindingElement.Multicast = multicast;
context.BindingElements.Add(udpBindingElement);
}
}
示例3: PrivacyNoticeBindingElement
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext)
{
if (policyContext == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policyContext");
}
XmlElement element = PolicyConversionContext.FindAssertion(policyContext.GetBindingAssertions(), "PrivacyNotice", "http://schemas.xmlsoap.org/ws/2005/05/identity", true);
if (element != null)
{
PrivacyNoticeBindingElement item = policyContext.BindingElements.Find<PrivacyNoticeBindingElement>();
if (item == null)
{
item = new PrivacyNoticeBindingElement();
policyContext.BindingElements.Add(item);
}
item.Url = new Uri(element.InnerText);
string attribute = element.GetAttribute("Version", "http://schemas.xmlsoap.org/ws/2005/05/identity");
if (string.IsNullOrEmpty(attribute))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CannotImportPrivacyNoticeElementWithoutVersionAttribute")));
}
int result = 0;
if (!int.TryParse(attribute, out result))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("PrivacyNoticeElementVersionAttributeInvalid")));
}
item.Version = result;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:PrivacyNoticeBindingElementImporter.cs
示例4: OnExportPolicy
internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
{
string str = "";
switch (this.Mode)
{
case SecurityMode.None:
str = "PeerTransportSecurityModeNone";
break;
case SecurityMode.Transport:
str = "PeerTransportSecurityModeTransport";
break;
case SecurityMode.Message:
str = "PeerTransportSecurityModeMessage";
break;
case SecurityMode.TransportWithMessageCredential:
str = "PeerTransportSecurityModeTransportWithMessageCredential";
break;
default:
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
}
XmlElement item = new XmlDocument().CreateElement("pc", "PeerTransportSecurityMode", "http://schemas.microsoft.com/soap/peer");
item.InnerText = str;
context.GetBindingAssertions().Add(item);
this.transportSecurity.OnExportPolicy(exporter, context);
}
示例5: OnImportPolicy
internal void OnImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
string str;
XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "PeerTransportSecurityMode", "http://schemas.microsoft.com/soap/peer", true);
this.Mode = SecurityMode.Transport;
if ((element != null) && ((str = element.InnerText) != null))
{
if (!(str == "PeerTransportSecurityModeNone"))
{
if (str == "PeerTransportSecurityModeTransport")
{
this.Mode = SecurityMode.Transport;
}
else if (str == "PeerTransportSecurityModeMessage")
{
this.Mode = SecurityMode.Message;
}
else if (str == "PeerTransportSecurityModeTransportWithMessageCredential")
{
this.Mode = SecurityMode.TransportWithMessageCredential;
}
}
else
{
this.Mode = SecurityMode.None;
}
}
this.transportSecurity.OnImportPolicy(importer, context);
}
示例6: OnImportPolicy
internal void OnImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(),
PeerTransportPolicyConstants.PeerTransportSecurityMode,
TransportPolicyConstants.PeerTransportUri, true);
this.Mode = SecurityMode.Transport;
if (element != null)
{
switch (element.InnerText)
{
case PeerTransportPolicyConstants.PeerTransportSecurityModeNone:
this.Mode = SecurityMode.None;
break;
case PeerTransportPolicyConstants.PeerTransportSecurityModeTransport:
this.Mode = SecurityMode.Transport;
break;
case PeerTransportPolicyConstants.PeerTransportSecurityModeMessage:
this.Mode = SecurityMode.Message;
break;
case PeerTransportPolicyConstants.PeerTransportSecurityModeTransportWithMessageCredential:
this.Mode = SecurityMode.TransportWithMessageCredential;
break;
default:
break;
}
}
transportSecurity.OnImportPolicy(importer, context);
}
示例7: if
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
if (importer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer");
}
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "OneWay", "http://schemas.microsoft.com/ws/2005/05/routing/policy", true);
if (element != null)
{
OneWayBindingElement item = new OneWayBindingElement();
context.BindingElements.Add(item);
for (int i = 0; i < element.ChildNodes.Count; i++)
{
System.Xml.XmlNode node = element.ChildNodes[i];
if (((node != null) && (node.NodeType == XmlNodeType.Element)) && ((node.NamespaceURI == "http://schemas.microsoft.com/ws/2005/05/routing/policy") && (node.LocalName == "PacketRoutable")))
{
item.PacketRoutable = true;
return;
}
}
}
else if (WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous)
{
context.BindingElements.Add(new OneWayBindingElement());
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:OneWayBindingElementImporter.cs
示例8: ArgumentNullException
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
if (importer == null)
{
throw new ArgumentNullException("importer");
}
if (context == null)
{
throw new ArgumentNullException("context");
}
ICollection<XmlElement> assertions = context.GetBindingAssertions();
foreach (XmlElement assertion in assertions)
{
if ((assertion.NamespaceURI == GZipMessageEncodingPolicyConstants.GZipEncodingNamespace) &&
(assertion.LocalName == GZipMessageEncodingPolicyConstants.GZipEncodingName)
)
{
assertions.Remove(assertion);
context.BindingElements.Add(new GZipMessageEncodingBindingElement());
break;
}
}
}
示例9: ArgumentNullException
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
if (importer == null)
{
throw new ArgumentNullException("importer");
}
if (context == null)
{
throw new ArgumentNullException("context");
}
ICollection<XmlElement> assertions = context.GetBindingAssertions();
foreach (XmlElement assertion in assertions)
{
if (assertion.NamespaceURI == MakeConnectionConstants.Namespace)
{
if (assertion.LocalName == MakeConnectionConstants.Policy.Assertion)
{
assertions.Remove(assertion);
context.BindingElements.Insert(0, new MakeConnectionBindingElement());
return;
}
}
}
}
示例10: OnImportPolicy
protected virtual void OnImportPolicy (XmlElement assertion,
MessageVersion messageVersion,
MetadataImporter exporter,
PolicyConversionContext context)
{
throw new NotImplementedException ();
}
示例11: GetReliableSessionBindingElement
private static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context)
{
ReliableSessionBindingElement item = context.BindingElements.Find<ReliableSessionBindingElement>();
if (item == null)
{
item = new ReliableSessionBindingElement();
context.BindingElements.Add(item);
}
return item;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:ReliableSessionBindingElementImporter.cs
示例12: GetReliableSessionBindingElement
static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context)
{
ReliableSessionBindingElement settings = context.BindingElements.Find<ReliableSessionBindingElement>();
if (settings == null)
{
settings = new ReliableSessionBindingElement();
context.BindingElements.Add(settings);
}
return settings;
}
示例13: ImportPolicy
public void ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
XmlQualifiedName wsdlBindingQName;
string transportUri = WsdlImporter.SoapInPolicyWorkaroundHelper.FindAdHocPolicy(context, this.udpTransportUriKey, out wsdlBindingQName);
if (transportUri != null && transportUri.Equals(UdpConstants.WsdlSoapUdpTransportUri, StringComparison.Ordinal) && !context.BindingElements.Contains(typeof(TransportBindingElement)))
{
UdpTransportBindingElement transport = new UdpTransportBindingElement();
((ITransportPolicyImport)transport).ImportPolicy(importer, context);
StateHelper.RegisterTransportBindingElement(importer, wsdlBindingQName);
context.BindingElements.Add(transport);
}
}
示例14: ArgumentNullException
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
if (importer == null)
{
throw new ArgumentNullException("importer");
}
if (context == null)
{
throw new ArgumentNullException("context");
}
ICollection<XmlElement> bindingAssertions = context.GetBindingAssertions();
List<XmlElement> processedAssertions = new List<XmlElement>();
UdpTransportBindingElement udpBindingElement = null;
bool multicast = false;
foreach (XmlElement assertion in bindingAssertions)
{
if (assertion.NamespaceURI != UdpPolicyStrings.UdpNamespace)
{
continue;
}
switch (assertion.LocalName)
{
case UdpPolicyStrings.TransportAssertion:
udpBindingElement = new UdpTransportBindingElement();
break;
case UdpPolicyStrings.MulticastAssertion:
multicast = true;
break;
default:
continue;
}
processedAssertions.Add(assertion);
}
if (udpBindingElement != null)
{
udpBindingElement.Multicast = multicast;
context.BindingElements.Add(udpBindingElement);
}
for (int i = 0; i < processedAssertions.Count; i++)
{
bindingAssertions.Remove(processedAssertions[i]);
}
}
示例15: CompositeDuplexBindingElement
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
if (importer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer");
}
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
if ((PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "CompositeDuplex", "http://schemas.microsoft.com/net/2006/06/duplex", true) != null) || (WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous))
{
context.BindingElements.Add(new CompositeDuplexBindingElement());
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:CompositeDuplexBindingElementImporter.cs