protected override void OnShutdown()
 {
     if (m_bIsMap)
       {
     ArcMap.Events.NewDocument -= ArcMap_NewOpenDocument;
     ArcMap.Events.OpenDocument -= ArcMap_NewOpenDocument;
       }
       m_FabricUTILS = null;
       s_extension = null;
       base.OnShutdown();
 }
        protected override void OnStartup()
        {
            s_extension = this;
              m_bIsCatalog = false;
              m_bIsMap = false;

              m_pApp = (IApplication)ArcMap.Application;

              if (m_pApp == null)
            //if the app is null then could be running from ArcCatalog
            m_pApp = (IApplication)ArcCatalog.Application;
              else
            m_bIsMap = true;

              if (m_pApp == null)
            return;
              else if (!m_bIsMap)
            m_bIsCatalog = true;

              if (m_bIsMap)
              {
            ArcMap.Events.NewDocument += ArcMap_NewOpenDocument;
            ArcMap.Events.OpenDocument += ArcMap_NewOpenDocument;
              }

              m_appStatusEvents = m_pApp as IApplicationStatusEvents_Event;
              m_appStatusEvents.Initialized += new IApplicationStatusEvents_InitializedEventHandler(appStatusEvents_Initialized);

              if (m_bIsMap)
              {
            m_pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");

            //get the extension
            UID pUID = new UIDClass();
            pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
            m_pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
              }
              m_FabricUTILS = new clsFabricUtils();
        }
        internal static CustomizelHelperExtension GetExtension()
        {
            if (s_extension == null)
              {
            // Call FindExtension to load extension.
            UID id = new UIDClass();
            id.Value = ThisAddIn.IDs.CustomizelHelperExtension;
            s_extension = (CustomizelHelperExtension)ArcMap.Application.FindExtensionByCLSID(id);
              }

              return s_extension;
        }