예제 #1
0
            static Version GetVersion(IAssemblyName name)
            {
                uint major;
                uint minor;

                name.GetVersion(out major, out minor);
                return(new Version((int)major >> 16, (int)major & 0xFFFF, (int)minor >> 16, (int)minor & 0xFFFF));
            }
예제 #2
0
        private static Version GetVersion(this IAssemblyName name)
        {
            uint versionHi, versionLow;

            name.GetVersion(out versionHi, out versionLow);
            return(new Version((int)(versionHi >> 16), (int)(versionHi & 0xFFFF),
                               (int)(versionLow >> 16), (int)(versionLow & 0xFFFF)));
        }
        internal static unsafe Version GetVersion(IAssemblyName nameObject)
        {
            uint hi, lo;
            int  hr = nameObject.GetVersion(out hi, out lo);

            if (hr != 0)
            {
                Debug.Assert(hr == FUSION_E_INVALID_NAME);
                return(null);
            }

            return(new Version((int)(hi >> 16), (int)(hi & 0xffff), (int)(lo >> 16), (int)(lo & 0xffff)));
        }
예제 #4
0
        /// <summary>
        /// Converts the value of this instance to its equivalent <see cref="AssemblyName"/>.
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <returns></returns>
        public static AssemblyName ToAssemblyName(this IAssemblyName assemblyName)
        {
            var result = new AssemblyName();

            result.Name        = assemblyName.GetName();
            result.Version     = assemblyName.GetVersion();
            result.CultureInfo = new CultureInfo(assemblyName.GetProperty <string>(AssemblyNamePropertyId.Culture));
            result.CodeBase    = assemblyName.GetProperty <string>(AssemblyNamePropertyId.CodebaseUrl);
            result.SetPublicKey(assemblyName.GetProperty <byte[]>(AssemblyNamePropertyId.PublicKey));
            result.SetPublicKeyToken(assemblyName.GetProperty <byte[]>(AssemblyNamePropertyId.PublicKeyToken));
            // Bug: The following line will always return null, why? And how to fix this?
            //  assemblyName.GetProperty<object>(AssemblyNamePropertyId.ProcessorIdArray);
            // A workaround is available by using the displayname of the IAssemblyName
            var tmp = assemblyName.GetDisplayName(DisplayNameFlags.ProcessArchitecture);

            tmp = tmp.Substring(tmp.LastIndexOf('=') + 1);
            if (Enum.IsDefined(typeof(ProcessorArchitecture), tmp))
            {
                result.ProcessorArchitecture = (ProcessorArchitecture)Enum.Parse(typeof(ProcessorArchitecture), tmp);
            }
            return(result);
        }
예제 #5
0
파일: GAC.cs 프로젝트: Robin--/Warewolf
 /// <summary>
 ///     Gets the version.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public static Version GetVersion(IAssemblyName name)
 {
     uint major;
     uint minor;
     name.GetVersion(out major, out minor);
     return new Version((int) major >> 16, (int) major & 0xFFFF, (int) minor >> 16, (int) minor & 0xFFFF);
 }
예제 #6
0
        internal static unsafe Version GetVersion(IAssemblyName nameObject)
        {
            uint hi, lo;
            int hr = nameObject.GetVersion(out hi, out lo);
            if (hr != 0)
            {
                Debug.Assert(hr == FUSION_E_INVALID_NAME);
                return null;
            }

            return new Version((int)(hi >> 16), (int)(hi & 0xffff), (int)(lo >> 16), (int)(lo & 0xffff));
        }
예제 #7
0
        private static Version GetVersion(IAssemblyName name)
        {
            uint majorOut;
            uint minorOut;
            name.GetVersion(out majorOut, out minorOut);

            int major = (int)majorOut >> 16;
            int minor = (int)majorOut & 0xFFFF;
            int build = (int)minorOut >> 16;
            int revision = (int)minorOut & 0xFFFF;

            if(major < 0)
            {
                major = major * -1;
            }

            if(minor < 0)
            {
                minor = minor * -1;
            }

            if(build < 0)
            {
                build = build * -1;
            }

            if(revision < 0)
            {
                revision = revision * -1;
            }

            return new Version(major, minor, build, revision);
        }