本文整理匯總了C#中System.ServiceModel.Description.IPolicyImportExtension接口的典型用法代碼示例。如果您正苦於以下問題:C# IPolicyImportExtension接口的具體用法?C# IPolicyImportExtension怎麽用?C# IPolicyImportExtension使用的例子?那麽, 這裏精選的接口代碼示例或許可以為您提供幫助。
IPolicyImportExtension接口屬於System.ServiceModel.Description命名空間,在下文中一共展示了IPolicyImportExtension接口的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ImportPolicy
#region IPolicyImporter Members
public const string name1 = "acme";
public const string ns1 = "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 void ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
Console.WriteLine("The custom policy importer has been called.");
// Locate the custom assertion and remove it.
XmlElement customAssertion = context.GetBindingAssertions().Remove(name1, ns1);
if (customAssertion != null)
{
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;
}
}
#endregion
示例2: typeof
// Download all metadata.
ServiceEndpointCollection endpoints
= MetadataResolver.Resolve(
typeof(IStatefulService),
new EndpointAddress("http://localhost:8080/StatefulService/mex")
);