int Common.IAppDomainMethod.ExecuteInDomain() { bool regFilePathCheckResult = PathUtils.TryCheckForValidLocalAndAbsoluteFileSystemPath(Settings.RegFilePath); if (!regFilePathCheckResult) { return((int)ResultCodes.InvalidRegfilePath); } AppDomain domain = AppDomain.CurrentDomain; Assembly addinAssembly = Assembly.LoadFile(Settings.AssemblyPath); IEnumerable <object> assemblyAttributes = AssemblyReflection.GetCustomAssemblyAttributes(addinAssembly); if (!AssemblyReflection.AssemblyIsComVisible(addinAssembly, assemblyAttributes)) { return((int)ResultCodes.AssemblyNotComVisible); } List <string> results = new List <string>(); 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; } string regContent = CreateRegistryFileContent(addinAssembly, assemblyAttributes, Settings.Mode, item, addinClassAttributes); object exportResult = DoExportCall(item); string exportValues = ProceedExportResult(exportResult); if (null != exportValues) { regContent += exportValues; } results.Add(regContent); } if (results.Count == 0) { return((int)ResultCodes.NothingFound); } WriteRegistryContentToLocalFileSystem(results); return((int)ResultCodes.Okay); }
int Common.IAppDomainMethod.ExecuteInDomain() { AppDomain domain = AppDomain.CurrentDomain; Assembly addinAssembly = Assembly.LoadFile(Settings.AssemblyPath); int signCheckResult = DoTokenCheck(addinAssembly); if (0 != signCheckResult) { return(signCheckResult); } DoMetrics(addinAssembly); IEnumerable <object> assemblyAttributes = AssemblyReflection.GetCustomAssemblyAttributes(addinAssembly); if (!AssemblyReflection.AssemblyIsComVisible(addinAssembly, assemblyAttributes)) { return((int)ResultCodes.AssemblyNotComVisible); } 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; } CreateRegistryEntries(addinAssembly, assemblyAttributes, Settings.Mode, item, addinClassAttributes); CreateOfficeKeys(item, addinClassAttributes, Settings.Mode == SingletonSettings.RegisterMode.System); if (Settings.DoRegisterCall) { if (!new Dispatcher.RegisterMethod().Call(item, Settings.Mode == SingletonSettings.RegisterMode.System ? 0 : 1, Settings.AddinRegMode == SingletonSettings.AddinRegMode.Off ? 0 : 1)) { return((int)ResultCodes.RegisterCallFailed); } } } return((int)ResultCodes.Okay); }
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); }