private static void UnregisterHandleDocumentInspector(Type type)
 {
     try
     {
         DocumentInspectorAttribute[] attributes = DocumentInspectorAttribute.GetAttributes(type);
         if (attributes.Length > 0)
         {
             RegistryLocationAttribute location = AttributeReflector.GetRegistryLocationAttribute(type);
             GuidAttribute             typeid   = AttributeReflector.GetGuidAttribute(type);
             foreach (var attribute in attributes)
             {
                 foreach (var version in attribute.ProcessedApplicationVersion)
                 {
                     DocumentInspectorAttribute.TryDeleteKey("Word", attribute.Name, version);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         NetOffice.DebugConsole.Default.WriteException(exception);
         if (!RegisterErrorHandler.RaiseStaticErrorHandlerMethod(type, RegisterErrorMethodKind.UnRegister, exception))
         {
             throw;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an registry tweak entry in the current addin key
        /// </summary>
        /// <param name="applicationType">target office application</param>
        /// <param name="addinType">addin class type informations</param>
        /// <param name="name">name for the tweak</param>
        /// <param name="value">value for the tweak</param>
        /// <param name="throwException">throw exception on error</param>
        /// <returns>true if value was stored otherwise false</returns>
        public static bool SetTweakPersistenceEntry(ApplicationIdentifiers.ApplicationType applicationType, Type addinType, string name, string value, bool throwException)
        {
            try
            {
                if (null == addinType)
                {
                    return(false);
                }
                RegistryLocationAttribute location = AttributeReflector.GetRegistryLocationAttribute(addinType);
                ProgIdAttribute           progID   = AttributeReflector.GetProgIDAttribute(addinType);

                OfficeApi.Tools.Contribution.RegistryLocationResult addinLocation =
                    Tools.Contribution.CommonUtils.TryFindAddinLoadLocation(addinType, applicationType);
                if (addinLocation == Office.Tools.Contribution.RegistryLocationResult.Unknown)
                {
                    return(false);
                }

                RegistryKey regKey = null;
                switch (addinLocation)
                {
                case Office.Tools.Contribution.RegistryLocationResult.User:
                    regKey = Registry.LocalMachine.OpenSubKey(_addinOfficeRegistryKey + progID.Value, true);
                    break;

                case Office.Tools.Contribution.RegistryLocationResult.System:
                    regKey = Registry.CurrentUser.OpenSubKey(_addinOfficeRegistryKey + progID.Value, true);
                    break;
                }

                if (null == regKey)
                {
                    return(false);
                }

                regKey.SetValue(name, value);
                regKey.Close();

                return(true);
            }
            catch (Exception exception)
            {
                NetOffice.DebugConsole.Default.WriteException(exception);
                if (throwException)
                {
                    throw;
                }
                else
                {
                    return(false);
                }
            }
        }
 private static void UnregisterHandleProgrammable(Type type, InstallScope scope)
 {
     try
     {
         ProgrammableAttribute programmable = AttributeReflector.GetProgrammableAttribute(type);
         if (null != programmable)
         {
             RegistryLocationAttribute location = AttributeReflector.GetRegistryLocationAttribute(type);
             bool isSystemComponent             = location.IsMachineComponentTarget(scope);
             ProgrammableAttribute.DeleteKeys(type.GUID, isSystemComponent, false);
         }
     }
     catch (Exception exception)
     {
         NetOffice.DebugConsole.Default.WriteException(exception);
         if (!RegisterErrorHandler.RaiseStaticErrorHandlerMethod(type, RegisterErrorMethodKind.UnRegister, exception))
         {
             throw;
         }
     }
 }
Ejemplo n.º 4
0
 private static void RegisterHandleRequireShutdownNotificationAttribute(Type type)
 {
     try
     {
         if (null != RequireShutdownNotificationAttribute.GetAttribute(type))
         {
             RegistryLocationAttribute location = AttributeReflector.GetRegistryLocationAttribute(type);
             bool            isSystem           = location.IsMachineAddinTarget();
             ProgIdAttribute progId             = AttributeReflector.GetProgIDAttribute(type);
             RequireShutdownNotificationAttribute.CreateApplicationKey(isSystem, _addinOfficeRegistryKey, progId.Value);
         }
     }
     catch (System.Exception exception)
     {
         DebugConsole.Default.WriteException(exception);
         if (!RegisterErrorHandler.RaiseStaticErrorHandlerMethod(type, RegisterErrorMethodKind.Register, exception))
         {
             throw;
         }
     }
 }
Ejemplo n.º 5
0
 private static void UnregisterHandleFormRegionAttribute(Type type)
 {
     try
     {
         var formAttributes = FormRegionAttribute.GetAttributes(type);
         foreach (var item in formAttributes)
         {
             RegistryLocationAttribute location = AttributeReflector.GetRegistryLocationAttribute(type);
             bool            isSystem           = location.IsMachineAddinTarget();
             ProgIdAttribute progId             = AttributeReflector.GetProgIDAttribute(type);
             FormRegionAttribute.TryDeleteKey(isSystem, _formRegionsOfficeRegistryKey, progId.Value, item.Category, item.Name);
         }
     }
     catch (System.Exception exception)
     {
         DebugConsole.Default.WriteException(exception);
         if (!RegisterErrorHandler.RaiseStaticErrorHandlerMethod(type, RegisterErrorMethodKind.Register, exception))
         {
             throw;
         }
     }
 }
 private static void UnregisterHandleCodebase(Type type, InstallScope scope)
 {
     try
     {
         CodebaseAttribute codebase = AttributeReflector.GetCodebaseAttribute(type);
         if (null != codebase && codebase.Value == true)
         {
             RegistryLocationAttribute location = AttributeReflector.GetRegistryLocationAttribute(type);
             bool     isSystemComponent         = location.IsMachineComponentTarget(scope);
             Assembly thisAssembly    = Assembly.GetAssembly(type);
             string   assemblyVersion = thisAssembly.GetName().Version.ToString();
             CodebaseAttribute.DeleteValue(type.GUID, isSystemComponent, assemblyVersion, false);
         }
     }
     catch (Exception exception)
     {
         NetOffice.DebugConsole.Default.WriteException(exception);
         if (!RegisterErrorHandler.RaiseStaticErrorHandlerMethod(type, RegisterErrorMethodKind.UnRegister, exception))
         {
             throw;
         }
     }
 }