Share via


MetadataExporter 類別

定義

將服務描述資訊匯出至中繼資料。

public ref class MetadataExporter abstract
public abstract class MetadataExporter
type MetadataExporter = class
Public MustInherit Class MetadataExporter
繼承
MetadataExporter
衍生

範例

下列程式碼範例是 IWsdlExportExtension.ExportContract 方法,示範如何使用類別 StateWsdlExporter 屬性,來附加可在端點中修改資料合約匯出的自訂 System.Runtime.Serialization.XsdDataContractExporter

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),使應用程式可以存取以實作使用服務的用戶端。 若要從 System.ServiceModel.Description.ServiceEndpoint 物件匯出中繼資料,請使用 MetadataExporter 抽象類別的實作。 MetadataExporter 實作會產生可封裝到 System.ServiceModel.Description.MetadataSet 執行個體的中繼資料。

MetadataExporter 類別所提供的架構可產生原則運算式,用來說明端點繫結程序及其相關作業、訊息與錯誤的各項功能與需求。 這些原則運算式是在 System.ServiceModel.Description.PolicyConversionContext 執行個體中擷取。 MetadataExporter 實作可接著將這些原則運算式附加到所產生的中繼資料中。

在產生 MetadataExporter 物件以供 System.ServiceModel.Channels.BindingElement 實作使用時,System.ServiceModel.Description.IPolicyExportExtension 會呼叫每個可於 ServiceEndpoint 繫結中實作 PolicyConversionContext 介面的 MetadataExporter。 您可以在自訂的 IPolicyExportExtension 型別實作中實作 System.ServiceModel.Channels.BindingElement 介面,以匯出新原則判斷提示。

類型 System.ServiceModel.Description.WsdlExporter 是 Windows Communication Foundation 隨附的 MetadataExporter 類別實作, (WCF) 。 WsdlExporter 型別會產生包含附加原則運算式的 WSDL 中繼資料。

若要針對端點行為、合約行為,或服務端點中的繫結項目匯出自訂 WSDL 中繼資料或 WSDL 延伸,您可以實作 System.ServiceModel.Description.IWsdlExportExtension 介面。 從服務端點產生 WSDL 文件時,WsdlExporter 型別會呼叫該端點中實作這個介面的部分。

屬性

Errors

取得在匯出中繼資料期間發生的錯誤集合。

PolicyVersion

指定所要使用的 WS-Policy 規格版本。

State

取得匯出中繼資料所使用的物件字典。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
ExportContract(ContractDescription)

在衍生類別中覆寫時,將合約描述匯出至中繼資料。

ExportEndpoint(ServiceEndpoint)

在衍生類別中覆寫時,將端點轉換成中繼資料。

ExportPolicy(ServiceEndpoint)

將原則判斷提示轉換成 PolicyConversionContext 物件。

GetGeneratedMetadata()

在衍生類別中覆寫時,會傳回呼叫 ExportContract(ContractDescription)ExportEndpoint(ServiceEndpoint)ExportPolicy(ServiceEndpoint) 所產生的中繼資料。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於