共用方式為


MetadataExporter.State 屬性

定義

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

public:
 property System::Collections::Generic::Dictionary<System::Object ^, System::Object ^> ^ State { System::Collections::Generic::Dictionary<System::Object ^, System::Object ^> ^ get(); };
public System.Collections.Generic.Dictionary<object,object> State { get; }
member this.State : System.Collections.Generic.Dictionary<obj, obj>
Public ReadOnly Property State As Dictionary(Of Object, Object)

屬性值

Dictionary<Object,Object>

匯入工具用來匯出合約和端點的物件字典。

範例

下列程式碼範例是 IWsdlExportExtension.ExportContract 方法,示範如何使用衍生類別 StateWsdlImporter 屬性,來附加可在端點中修改資料合約匯出的自訂 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();

備註

您可以使用 State 屬性來傳遞成功匯出端點或合約所需的 MetadataExporter 狀態資料。

適用於