internal static AddinClassInformations Create(Assembly addinAssembly, IEnumerable <object> assemblyAttributes, SingletonSettings.RegisterMode mode, Type addinClassType, IEnumerable <object> addinClassAttributes) { AssemblyName binaryHeader = addinAssembly.GetName(); string assemblyName = binaryHeader.Name; string assemblyVersion = binaryHeader.Version.ToString(); string assemblyCulture = CultureInfoConversion.ConvertToString(binaryHeader.CultureInfo); string assemblyToken = TokenConversion.ConvertToString(binaryHeader.GetPublicKeyToken()); string runtimeVersion = addinAssembly.ImageRuntimeVersion; string[] classesRoot = new string[] { mode == SingletonSettings.RegisterMode.System ? "HKEY_CLASSES_ROOT" : "HKEY_CURRENT_USER\\Software\\Classes" }; string progid = AttributeReflection.GetAttribute <ProgIdAttribute>(addinClassAttributes).Value; string fullClassName = addinClassType.FullName; string id = AttributeReflection.GetAttribute <GuidAttribute>(addinClassAttributes).Value; string codebase = addinAssembly.CodeBase; AddinClassInformations result = new AddinClassInformations( assemblyName, assemblyVersion, assemblyCulture, assemblyToken, runtimeVersion, classesRoot, progid, fullClassName, id, codebase); return(result); }
internal static AddinClassInformation Create(Assembly addinAssembly, IEnumerable <object> assemblyAttributes, SingletonSettings.UnRegisterMode mode, Type addinClassType, IEnumerable <object> addinClassAttributes) { AssemblyName binaryHeader = addinAssembly.GetName(); string assemblyName = binaryHeader.Name; string assemblyVersion = binaryHeader.Version.ToString(); string assemblyCulture = CultureInfoConversion.ConvertToString(binaryHeader.CultureInfo); string assemblyToken = TokenConversion.ConvertToString(binaryHeader.GetPublicKeyToken()); string runtimeVersion = addinAssembly.ImageRuntimeVersion; string[] classesRoot = null; switch (mode) { case SingletonSettings.UnRegisterMode.Auto: classesRoot = new string[] { "HKEY_CLASSES_ROOT", "HKEY_CURRENT_USER\\Software\\Classes" }; break; case SingletonSettings.UnRegisterMode.System: classesRoot = new string[] { "HKEY_CLASSES_ROOT" }; break; case SingletonSettings.UnRegisterMode.User: classesRoot = new string[] { "HKEY_CURRENT_USER\\Software\\Classes" }; break; default: throw new IndexOutOfRangeException("mode"); } string progid = AttributeReflection.GetAttribute <ProgIdAttribute>(addinClassAttributes).Value; string fullClassName = addinClassType.FullName; string id = AttributeReflection.GetAttribute <GuidAttribute>(addinClassAttributes).Value; string codebase = addinAssembly.CodeBase; AddinClassInformation result = new AddinClassInformation( assemblyName, assemblyVersion, assemblyCulture, assemblyToken, runtimeVersion, classesRoot, progid, fullClassName, id, codebase); return(result); }