Export (0) Print
Expand All

MetadataExporter.State Property

Gets a dictionary of objects used in the export of metadata.

Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public Dictionary<Object, Object> State { get; }

Property Value

Type: System.Collections.Generic.Dictionary<Object, Object>
A dictionary of objects used by the importer to export contracts and endpoints.

Use the State property to pass a MetadataExporter state data required to successfully export endpoints or contracts.

The following code example is an IWsdlExportExtension.ExportContract method that demonstrates how the State property of the derived class WsdlImporter 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();


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft