int Common.IAppDomainMethod.ExecuteInDomain() { AppDomain domain = AppDomain.CurrentDomain; Assembly addinAssembly = Assembly.LoadFile(Settings.AssemblyPath); int signCheckResult = DoTokenCheck(addinAssembly); if (0 != signCheckResult) { return(signCheckResult); } IEnumerable <object> assemblyAttributes = AssemblyReflection.GetCustomAssemblyAttributes(addinAssembly); Type[] types = addinAssembly.GetExportedTypes(); foreach (Type item in types) { if (!item.IsClass) { continue; } IEnumerable <object> addinClassAttributes = Common.AttributeReflection.GetCustomClassAttributes(item); if (!AddinClassReflection.IsValidAddinClass(addinClassAttributes, item.Attributes)) { continue; } AddinRegAnalyzer.KeyTarget target = AddinRegAnalyzer.KeyTarget.Both; switch (Settings.Mode) { case SingletonSettings.UnRegisterMode.Auto: target = AddinRegAnalyzer.KeyTarget.Both; break; case SingletonSettings.UnRegisterMode.System: target = AddinRegAnalyzer.KeyTarget.System; break; case SingletonSettings.UnRegisterMode.User: target = AddinRegAnalyzer.KeyTarget.User; break; default: throw new IndexOutOfRangeException("Mode"); } DeleteRegistryEntries(addinAssembly, assemblyAttributes, Settings.Mode, item, addinClassAttributes); DeleteOfficeKeys(item, addinClassAttributes, target); if (Settings.DoRegisterCall) { int installScope = Settings.Mode == SingletonSettings.UnRegisterMode.System ? 0 : 1; int keyState = Settings.AddinRegMode == SingletonSettings.AddinRegMode.Off ? 0 : 1; if (!new Dispatcher.UnRegisterMethod().Call(item, installScope, keyState)) { return((int)ResultCodes.UnRegisterCallFailed); } } } return((int)ResultCodes.Okay); }
private void DeleteOfficeKeys(Type addin, IEnumerable <object> addinClassAttributes, AddinRegAnalyzer.KeyTarget keyTarget) { if (Settings.AddinRegMode == SingletonSettings.AddinRegMode.On) { AddinRegAnalyzer reg = new AddinRegAnalyzer(); reg.DeleteKey(addin, addinClassAttributes, keyTarget); } }