This document is archived and information here might be outdated.  Recommended version.

Adding a plug-in data source programmatically (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Extending ArcObjects > Geodatabase customizations > Plug-in data sources > Adding a plug-in data source programmatically

Adding a plug-in data source programmatically

ArcGIS deals with several read-only data sources, such as StreetMap, computer-aided design (CAD), and Smart Data Compression (SDC) formats used by RouteMAP IMS. A plug-in data source integrates a new data format completely into ArcGIS, albeit in a read-only manner. The data source can be programmed with using normal geodatabase interfaces, such as, IWorkspace and IFeatureClass.

Accessing a plug-in data source programmatically

One of the advantages of plug-in data sources is that once implemented, they can be accessed by client developers using the normal geodatabase ArcObjects application programming interface (API). Only the interfaces with names starting with IPlugIn must be used when implementing the data source.
One problem that can be encountered is that no type library information will be available for the workspace factory, so late binding must be used to create the object via its ProgID.
The ProgID of a workspace factory can be found by using the Component Category Manager tool to inspect the ESRI Workspace Factories category. The ProgID is derived from the return value of the DataSourceName property of the IPlugInWorkspaceFactoryHelper interface and is given in the following format:
  • ProgID=esriGeoDatabase.<DataSourceName>WorkspaceFactory
For example, if the returning DataSourceName property of PlugInWorkspaceFactoryHelper is SimplePointPlugin, the plug-in ProgID will be as follows:
  • esriGeoDatabase.SimplePointPluginWorkspaceFactory
The following code example shows how to access a plug-in data source programmatically and add a feature class to the map:
//Get the type using the ProgID.
Type t=Type.GetTypeFromProgID("esriGeoDatabase.SimplePointPluginWorkspaceFactory");

//Use activator to create an instance of the workspace factory.
IWorkspaceFactory workspaceFactory=Activator.CreateInstance(t)as IWorkspaceFactory;

//Open the workspace.
IFeatureWorkspace featureWorkspace=(IFeatureWorkspace)
    workspaceFactory.OpenFromFile(@"C:\Data\Data", 0);

//Get a feature class from the workspace.
IFeatureClass featureClass=featureWorkspace.OpenFeatureClass("points");

//Create a feature layer and add it to the map.
IFeatureLayer featureLayer=new FeatureLayerClass();
'Get the type using the ProgID.
Dim t As Type=Type.GetTypeFromProgID("esriGeoDatabase.SimplePointPluginWorkspaceFactory")

'Use activator to create an instance of the workspace factory.
Dim workspaceFactory As IWorkspaceFactory=TryCast(Activator.CreateInstance(t), IWorkspaceFactory)

'Open the workspace.
Dim featureWorkspace As IFeatureWorkspace=CType(workspaceFactory.OpenFromFile("C:\Data\Data", 0), IFeatureWorkspace)

'Get a feature class from the workspace.
Dim featureClass As IFeatureClass=featureWorkspace.OpenFeatureClass("points")

'Create a feature layer and add it to the map.
Dim featureLayer As IFeatureLayer=New FeatureLayerClass()
m_hookHelper.FocusMap.AddLayer(CType(featureLayer, ILayer))
You can also open the workspace with IWorkspaceFactory.Open. In this case, supply a property set with a single property of DATABASE and the appropriate workspace string. Another way of opening the workspace is to use a WorkspaceName object; set the WorkspaceFactoryProgID and PathName properties, then call IName.Open.

See Also:

Plug-in data sources
Creating a plug-in data source
Sample: Simple point plug-in data source

Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced