ArcGIS Engine Editor – Editor Extension in ArcGIS Engine 10 Application

arcgis-10.0arcgis-engine

How can I find the Editor extension in an ArcGIS Engine application (i.e. no access to the IApplication object)?

There is an example method at http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000004nn000000

private void GetEditorExtension(IApplication application)
{
    //Find extension by CLSID or ProgId.
    UID extensionID = new UIDClass();
    extensionID.Value = "esriEditor.Editor"; 
        //{F8842F20-BB23-11D0-802B-0000F8037368}.
    IExtension editExtension = application.FindExtensionByCLSID(extensionID);
}

However, IApplication is only available for code that runs directly in ArcMap, not stand-alone apps.

If it helps, I'm writing this inside a custom tool, so I also have acces to the HookHelperClass.

Best Answer

The editor class is an arcmap extension, and is not available with standalone (arcengine) applications.

For ArcEngine try using the EngineEditor singleton class. According to this sample, you can use "new" to get a reference to it. Note that in other situations Esri advises to use activator for instantiation of singletons, but I guess that doesn't apply in this case(?).

It is unfortunate that EngineEditor doesn't implement IExtensionManager. The Editor coclass implements this to support Editor Extensions. Maybe you could write EngineEditor extensions by leveraging the ExtensionManager singleton, which is available in ArcEngine.

If you don't want to hardwire your EngineEditor Extensions you might consider using ICategoryFactory to scan through a category for UID's of registered EngineExtensions, or better yet, store the extensions' assemblies in the geodatabase. After instantiating each extension, call IExtension.Startup and pass a reference to the IEngineEditor. This gives the extension an opportunity to subscribe to IEngineEditEvents, and intercept CRUD operations before they complete so you can enforce business rules.

Related Question