コード例 #1
0
 internal static bool IsValidAddinClass(IEnumerable <object> customAttributes)
 {
     if (false == AttributeReflection.ComVisibleAttributeExists(customAttributes) ||
         false == AttributeReflection.GuidAttributeExists(customAttributes) ||
         false == AttributeReflection.ProgIdAttributeExists(customAttributes))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #2
0
        internal static bool IsValidAddinClass(IEnumerable <object> customAttributes, TypeAttributes typeAttributes)
        {
            TypeAttributes isPublic = typeAttributes & TypeAttributes.Public;

            if (isPublic != TypeAttributes.Public)
            {
                return(false);
            }

            if (false == AttributeReflection.ComVisibleAttributeExists(customAttributes) ||
                false == AttributeReflection.GuidAttributeExists(customAttributes) ||
                false == AttributeReflection.ProgIdAttributeExists(customAttributes))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }