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 方法,该方法演示如何使用 State 派生类的 WsdlImporter 属性来附加用于修改终结点中数据协定的导出的自定义 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 状态数据,以成功导出终结点或协定。

适用于