示例#1
0
文件: GACUtil.cs 项目: zha0/wspe
        /// <summary>
        /// Get the name of an Assembly.
        /// </summary>
        /// <param name="pIAssemblyName">Pointer to an IAssemblyName interface.</param>
        /// <param name="wszAssemblyName">Pointer to the name of the Assembly.</param>
        /// <returns>Whether the function successfully executed.</returns>
        public uint GetAssemblyName(ref IAssemblyName pIAssemblyName, ref string wszAssemblyName)
        {
            if (pIAssemblyName == null)
            {
                return(Macros.E_FAIL);
            }

            uint uBufferSize = 0;

            pIAssemblyName.GetName(ref uBufferSize, null);
            if (uBufferSize == 0)
            {
                return(Macros.E_FAIL);
            }

            StringBuilder bob = new StringBuilder((int)uBufferSize);
            uint          hr  = pIAssemblyName.GetName(ref uBufferSize, bob);

            if (!Macros.SUCCEEDED(hr))
            {
                return(Macros.E_FAIL);
            }

            wszAssemblyName = bob.ToString();
            return(Macros.S_OK);
        }
示例#2
0
 private static string GetName(IAssemblyName name)
 {
     uint bufferSize = 255;
     var stringBuilder = new StringBuilder((int)bufferSize);
     name.GetName(ref bufferSize, stringBuilder);
     return stringBuilder.ToString().Trim();
 }
示例#3
0
            static String GetName(IAssemblyName name)
            {
                uint          bufferSize = 255;
                StringBuilder buffer     = new StringBuilder((int)bufferSize);

                name.GetName(ref bufferSize, buffer);
                return(buffer.ToString());
            }
示例#4
0
        private static string GetName(this IAssemblyName name)
        {
            uint bufferSize = 255;
            var  buffer     = new StringBuilder((int)bufferSize);

            name.GetName(ref bufferSize, buffer);
            return(buffer.ToString());
        }
示例#5
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);
        }
示例#6
0
文件: GAC.cs 项目: Robin--/Warewolf
 /// <summary>
 ///     Gets the name.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public static String GetName(IAssemblyName name)
 {
     uint bufferSize = 255;
     var buffer = new StringBuilder((int) bufferSize);
     name.GetName(ref bufferSize, buffer);
     return buffer.ToString();
 }