Pitney Bowes MapXtreme User Manual

Page 510

Advertising
background image

Appendix D: Extensible Data Providers

Advanced Topics / Important Considerations

MapXtreme v7.1

517

Developer Guide

SupportsDataProvider() is used to identify providers responsible for ITableDefinition and
IDataSourceDefinition constructs for a given IDataProvider. Generally, persistence providers are
written to support a single data provider, so the implementation for this method can often be as
simple as determining if the provided IDataProvider is an instance of your data provider class.

The SupportsSchemaNamespace and SupportsEntityName work in tandem during workspace
depersistence to identify the persistence provider supporting a namespace and tag name identified
for extensible data provider content. For example, when reading through the workspace file, the
following content is encountered for an extensible data provider:

<sample:SampleTableDefinition xmlns:sample="http://sample/sample">
<sample:TableName>test</sample:TableName>
</sample:SampleTableDefinition>

An XMLNode object reference is obtained for the outer tag. The NamespaceURI property ("sample")
is provided to SupportsSchemaNamespace, and the LocalName property ("SampleTableDefinition")
is provided to SupportsEntityName to identify a persistence provider supporting both. The
constructor signature available through the abstract class also supports default implementations of
these methods.

The AbstractMxpPersistenceProvider contains a constructor signature that works in conjunction with
the default implementation of IMxpPersistenceProvider.Schema to return an XMLSchema reference
to an .xsd schema file attached as an embedded resource within your assembly. See the Developer
Reference for details.

The remaining methods on IMxpPersistenceProvider are the read/write pairings for data source and
table definitions. For data providers that do not use data sources, only the read/write methods for the
table definitions require implementation. If data sources are applicable, the data source definitions
would need to be persisted. MapXtreme handles that for you. You can focus exclusively on
persisting only those table definition properties that are unique to your table.

The read methods contain an XmlElement handle to the XML tag for the extensible content. The
components of the data source and table definitions are managed as child nodes within that
element. Following the SampleTableDefinition example above, the implementation code might
resemble the following:

ITableDefinition td = null;
if (node.LocalName.Equals("SampleTableDefinition") &&
node.NamespaceURI("http://sample/sample"))
{

string tableName = null;
foreach (XmlNode childNode in node.ChildNodes)
{

if (childNode.LocalName.Equals("TableName") &&
childNode.NamespaceURI.Equals("http://sample/sample"))

{

tableName = childNode.InnerText;

}

}
td = new SampleTableDefinition(tableName);

}

Advertising