MetadataExporter 类
定义
将服务说明信息导出到元数据中。Exports service description information into metadata.
public ref class MetadataExporter abstract
public abstract class MetadataExporter
type MetadataExporter = class
Public MustInherit Class MetadataExporter
- 继承
-
MetadataExporter
- 派生
示例
下面的代码示例为一个 IWsdlExportExtension.ExportContract 方法,该方法演示如何使用 State 类的 WsdlExporter 属性来附加用于修改终结点中数据协定的导出的自定义 System.Runtime.Serialization.XsdDataContractExporter。The following code example is an IWsdlExportExtension.ExportContract method that demonstrates how the State property of the class WsdlExporter is used to attach a custom System.Runtime.Serialization.XsdDataContractExporter that modifies the export of data contracts in the endpoint.
public void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
{
// Add a custom DCAnnotationSurrogate to write data contract comments into the XSD.
object dataContractExporter;
XsdDataContractExporter xsdDCExporter;
if (!exporter.State.TryGetValue(typeof(XsdDataContractExporter), out dataContractExporter))
{
xsdDCExporter = new XsdDataContractExporter(exporter.GeneratedXmlSchemas);
exporter.State.Add(typeof(XsdDataContractExporter), xsdDCExporter);
}
else
{
xsdDCExporter = (XsdDataContractExporter)dataContractExporter;
}
if (xsdDCExporter.Options == null)
xsdDCExporter.Options = new ExportOptions();
xsdDCExporter.Options.DataContractSurrogate = new DCAnnotationSurrogate();
注解
元数据导出是一个过程,用于描述服务终结点并将服务终结点映射到并行的标准化表示形式(通常但不一定为 XML),应用程序可使用该表示形式来实现使用此服务的客户端。Metadata export is the process of describing service endpoints and projecting them into a parallel, standardized representation (typically, but not necessarily XML) that applications can access to implement a client that uses the service. 若要从 System.ServiceModel.Description.ServiceEndpoint 对象导出元数据,请使用 MetadataExporter 抽象类的实现。To export metadata from System.ServiceModel.Description.ServiceEndpoint objects, use an implementation of the MetadataExporter abstract class. MetadataExporter 实现生成包装在 System.ServiceModel.Description.MetadataSet 实例中的元数据。A MetadataExporter implementation generates metadata that is encapsulated in a System.ServiceModel.Description.MetadataSet instance.
MetadataExporter 类提供一个框架,该框架用于生成描述终结点绑定的功能和要求及其关联的操作、消息和错误的策略表达式。The MetadataExporter class provides a framework for generating policy expressions that describe the capabilities and requirements of an endpoint binding and its associated operations, messages and faults. 在 System.ServiceModel.Description.PolicyConversionContext 实例中可捕获这些策略表达式。These policy expressions are captured in a System.ServiceModel.Description.PolicyConversionContext instance. 然后 MetadataExporter 实现可以将这些策略表达式附加到它生成的元数据。A MetadataExporter implementation can then attach these policy expressions to the metadata it generates.
当生成供 MetadataExporter 实现使用的 System.ServiceModel.Channels.BindingElement 对象时,System.ServiceModel.Description.IPolicyExportExtension 调入在 ServiceEndpoint 的绑定中实现 PolicyConversionContext 接口的每个 MetadataExporter。The MetadataExporter calls into each System.ServiceModel.Channels.BindingElement that implements the System.ServiceModel.Description.IPolicyExportExtension interface in the binding of a ServiceEndpoint when generating a PolicyConversionContext object for the MetadataExporter implementation to use. 通过在 IPolicyExportExtension 类型的自定义实现上实现 System.ServiceModel.Channels.BindingElement 接口,可以导出新策略断言。You can export new policy assertions by implementing the IPolicyExportExtension interface on your custom implementations of the System.ServiceModel.Channels.BindingElement type.
System.ServiceModel.Description.WsdlExporter类型是 MetadataExporter WINDOWS COMMUNICATION FOUNDATION (WCF) 中包含的类的实现。The System.ServiceModel.Description.WsdlExporter type is the implementation of the MetadataExporter class included with Windows Communication Foundation (WCF). WsdlExporter 类型使用附加的策略表达式生成 WSDL 元数据。The WsdlExporter type generates WSDL metadata with attached policy expressions.
若要为服务终结点中的终结点行为、协定行为或绑定元素导出自定义 WSDL 元数据或 WSDL 扩展,您可以实现 System.ServiceModel.Description.IWsdlExportExtension 接口。To export custom WSDL metadata or WSDL extensions for endpoint behaviors, contract behaviors or binding elements in a service endpoint, you can implement the System.ServiceModel.Description.IWsdlExportExtension interface. 当从服务终结点生成 WSDL 文档时,WsdlExporter 类型调入实现此接口的部分服务终结点。The WsdlExporter type calls into parts of a service endpoint that implement this interface when generating the WSDL document from that endpoint.
属性
| Errors |
获取元数据导出过程中发生的错误的集合。Gets a collection of errors that occurred during metadata export. |
| PolicyVersion |
指定正在使用的 WS-Policy 规范的版本。Specifies the version of WS-Policy specification being used. |
| State |
获取在元数据的导出中使用的对象的词典。Gets a dictionary of objects used in the export of metadata. |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| ExportContract(ContractDescription) |
当在派生类中重写时,将协定描述导出到元数据中。When overridden in a derived class, exports a contract description into metadata. |
| ExportEndpoint(ServiceEndpoint) |
当在派生类中重写时,将终结点转换为元数据。When overridden in a derived class, converts an endpoint into metadata. |
| ExportPolicy(ServiceEndpoint) |
将策略断言转换为 PolicyConversionContext 对象。Converts policy assertions into a PolicyConversionContext object. |
| GetGeneratedMetadata() |
当在派生类中重写时,返回由对 ExportContract(ContractDescription), ExportEndpoint(ServiceEndpoint) 或 ExportPolicy(ServiceEndpoint) 的调用生成的元数据。When overridden in a derived class, returns the metadata generated by a call to either ExportContract(ContractDescription), ExportEndpoint(ServiceEndpoint), or ExportPolicy(ServiceEndpoint). |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |