本文整理汇总了VB.NET中System.ServiceModel.Description.IPolicyImportExtension.ImportPolicy方法的典型用法代码示例。如果您正苦于以下问题:VB.NET IPolicyImportExtension.ImportPolicy方法的具体用法?VB.NET IPolicyImportExtension.ImportPolicy怎么用?VB.NET IPolicyImportExtension.ImportPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Description.IPolicyImportExtension
的用法示例。
在下文中一共展示了IPolicyImportExtension.ImportPolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: ImportPolicy
#Region "IPolicyImporter Members"
Public Const name1 As String = "acme"
Public Const ns1 As String = "http://Microsoft/WCF/Documentation/CustomPolicyAssertions"
'
' * Importing policy assertions usually means modifying the bindingelement stack in some way
' * to support the policy assertion. The procedure is:
' * 1. Find the custom assertion to import.
' * 2. Insert a supporting custom bindingelement or modify the current binding element collection
' * to support the assertion.
' * 3. Remove the assertion from the collection. Once the ImportPolicy method has returned,
' * any remaining assertions for the binding cause the binding to fail import and not be
' * constructed.
'
Public Sub ImportPolicy(ByVal importer As MetadataImporter, ByVal context As PolicyConversionContext) Implements IPolicyImportExtension.ImportPolicy
Console.WriteLine("The custom policy importer has been called.")
' Locate the custom assertion and remove it.
Dim customAssertion As XmlElement = context.GetBindingAssertions().Remove(name1, ns1)
If customAssertion IsNot Nothing Then
Console.WriteLine("Removed our custom assertion from the imported " & "assertions collection and inserting our custom binding element.")
' Here we would add the binding modification that implemented the policy.
' This sample does not do this.
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine(customAssertion.NamespaceURI & " : " & customAssertion.Name)
Console.WriteLine(customAssertion.OuterXml)
Console.ForegroundColor = ConsoleColor.Gray
End If
End Sub
#End Region
开发者ID:VB.NET开发者,项目名称:System.ServiceModel.Description,代码行数:29,代码来源:IPolicyImportExtension.ImportPolicy