Exception handling – Pitney Bowes MapXtreme User Manual

Page 508

Advertising
background image

Appendix D: Extensible Data Providers

Advanced Topics / Important Considerations

MapXtreme v7.1

515

Developer Guide

IGeometryColumn.DefaultStyle

A style attribute column is not required when you want to apply a single style uniformly when
rendering the objects within one of the table’s feature geometry columns. For this, a style object
instance can be directly managed as the DefaultStyle property of the feature geometry column
(IGeometryColumn.DefaultStyle).

Providing a default style is always recommended, even when a style column exists. The default style
is used to fill in missing style attribute values if the style column contains null or missing values. In
the absence of an explicitly provided default style, MapXtreme does have an internal default style it
can apply as needed.

If using only a default style on the feature geometry column, a style column will still be shown in the
columns collection associated with the resulting Table instance opened within the Catalog. This
column will be nullable and read-only, and all values are defaulted to the specified default style
instance value.

While no explicit proscription is made against defining multiple geometry column and/or multiple
style column data configurations within your extensible data provider implementation, the metadata
model does not support the explicit association of a style column to a geometry column. When
rendering a map layer, there’s an implicit assumption that the table servicing that layer contains a
single geometry column with at most one adjacent style column. Similarly, where the model also
permits extensible data providers to define tables containing style columns without an adjacent
geometry column, these tables cannot currently be cached, and may not be exportable to other
formats.

Exception Handling

Exception handling in the data provider is very important. The data provider will usually be handling
system resources such as file handles or database connections. If these resources are not carefully
cleaned up in normal and exception code paths, they may be leaked giving applications unusual
behaviors or memory leaks that build up over time. These problems are often accentuated in web
applications that utilize pooled sessions in which memory leaks may eventually cause the system to
shut down or multiple processes to hang waiting for leaked connections to be released.

Exceptions thrown should follow standard .NET practices as prescribed by Microsoft in

Best

Practices for Handling Exceptions

. When throwing a custom exception, use the

MapInfo.Data.Provider.DataProviderException class. This class may be subclassed to provide
additional behavior if necessary.

Exception handling is also a good time to think about externalizing the resources for your data
provider. By properly capturing resources such as strings, bitmaps, etc. in resource files, your data
provider can be localized for other cultures. The SpatiaLite Data Provider sample provides a
reference implementation for handling resource strings for exception handling (refer to the
Resources.cs file in the project).

Advertising