Pitney Bowes MapXtreme User Manual
Page 515

Appendix D: Extensible Data Providers
Advanced Topics / Important Considerations
MapXtreme v7.1
522
Developer Guide
A typical example of a callback is one which, in a desktop application environment, the
OpenDataSource callback resolves a credential authentication error by presenting the user with a
dialog, requesting a valid username/password combination for the data provider.
Implementing Your Data Provider Callback
The IDataProviderCallback interface specifies method signatures for modifying data both of the
IDataSourceDefinition and ITableDefinition data provider definition types. Classes implementing
IDataProviderCallback must provide appropriate implementations of the methods to provide run-time
updates of the definition objects in order to fulfill the OpenDataSource/OpenTable requirements.
Additionally, an IDataProviderCallbackInfo interface can be specified on the callback method in
order to provide additional runtime state information to the callback in order to determine an
appropriate course of action. The IDataProviderCallbackInfo is a marker interface only, and does not
specify the nature of the information provided to the callback. Typical implementations could include
a run-time Exception or state enumeration attribute.
The MapInfo.Data.Provider namespace contains a canonical implementation that may be used by
Data Provider implementors and/or client applications. The DataProviderCallback class implements
a delegate-based callback harness, allowing client code to assign a callback method outside of the
Extensible Data Provider assembly. The DataProviderCallbackExceptionInfo class implements
IDataProviderCallbackInfo as a carrier for a System.Exception reference, while the
DataProviderCallbackCollection implements an ICollection of IDataProviderCallback[s].
The following is an example of how a credential resolution callback scenario can be implemented.
// Create a method to handle the OpenDataSource InvalidCredentials state
// Implements IDataProviderCallback.Callback signature
public static IDataSourceDefinition InvalidCredentialsCb(
IDataSourceDefinition dsd, IDataProviderCallbackInfo info)
{
// Implementation details are specific to the Data Provider,
specifically, to the appropriate IDataSourceDefinition implementation
DataProviderCallbackExceptionInfo pcinfo
= info as DataProviderCallbackExceptionInfo;
if (pcinfo != null)
{
if (pcinfo.Exception == /* invalid credentials */)
{
// Example: present user dialog
string newpwd = GetPasswordFromUser();
// Example: create new EDP implementation specific DataSourceDefinition
// with updated password credentials
return new EDPDataSourceDefinition(newpwd);
}
}
}
// MXT/EDP client code
{
// Create a callback harness and assign the callback method