Select to view content in your preferred language

Replacement for extending AddIns.Extension

350
2
11-22-2019 03:33 PM
LesleyBross1
Regular Contributor

With ArcMap AddIns, I extended the AddIns.Extension class to create a custom extension as a central repository to store states and variables that were relevant to different workflows in my AddIn. For example: the currently selected area of interest. To access the custom extension from any workflow in the AddIn, I used the Application.FindExtensionByCLSID() method. Is there a recommended design pattern for centrally storing this type of information in ArcGIS Pro?

Friend Shared Function GetExtension() As BagisPExtension
  ' Extension loads just in time, call FindExtension to load it.
  If s_extension Is Nothing Then
    Dim extID As UID = New UID()
    extID.Value = My.AddInID
    My.ArcMap.Application.FindExtensionByCLSID(extID)
  End If
Return s_extension
End Function

0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

Hi Lesley

The recommended way to store properties to be used across an add-in is to use the Module class file.

In an add-in, you will have a Module1.cs class file. For convenience,  the "Current" property is created in the add-in when you use the Pro SDK Templates to create an add-in. Instance properties in the Module1 class can be accessed across the add-in as Module1.Current.<PropertyName>.  Static properties can be accessed directly using Module1.<StaticProperty>.

You will see this pattern in many of the samples in the arcgis-pro-community-samples repository.

Thanks

Uma

LesleyBross1
Regular Contributor

Thanks Uma ~

That works! For others trying to do something similar, the ArcGISOnlineConnect project in the samples was the closest to what I was trying to do.

0 Kudos