当前位置: 首页>>代码示例>>C#>>正文


C# IPolicyImportExtension接口代码示例

本文整理汇总了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
开发者ID:.NET开发者,项目名称:System.ServiceModel.Description,代码行数:34,代码来源:IPolicyImportExtension

示例2: typeof

// Download all metadata. 
ServiceEndpointCollection endpoints
  = MetadataResolver.Resolve(
    typeof(IStatefulService),
    new EndpointAddress("http://localhost:8080/StatefulService/mex")
  );
开发者ID:.NET开发者,项目名称:System.ServiceModel.Description,代码行数:6,代码来源:IPolicyImportExtension


注:本文中的System.ServiceModel.Description.IPolicyImportExtension接口示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。