コード例 #1
0
        //D:\NewProject\ProjectX\Bin\Server\Message.ClientProtocol.dll
        /// <summary>
        /// 获取程序集名称列表
        /// </summary>
        /// <returns></returns>
        public AssemblyResult GetAssemblyName()
        {
            AssemblyResult result = new AssemblyResult();

            string[] dicFileName = Directory.GetFileSystemEntries(path);
            if (dicFileName != null)
            {
                List <string> assemblyList = new List <string>();
                foreach (var item in dicFileName)
                {
                    assemblyList.Add(item.Substring(item.LastIndexOf('/') + 1));
                }
                result.AssemblyNameList = assemblyList;
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 获取程序集中的类名
        /// </summary>
        /// <param name="assemblyName">程序集</param>
        /// <returns></returns>
        public AssemblyResult GetClassName(string assemblyName)
        {
            AssemblyResult result = new AssemblyResult();

            if (!String.IsNullOrEmpty(assemblyName))
            {
                Assembly assembly = Assembly.LoadFrom(assemblyName);
                result.Assembly = assembly;
                Type[] types = assembly.GetTypes();
                Dictionary <string, Type> classTypeList = new Dictionary <string, Type>();
                foreach (var item in types)
                {
                    if (classTypeList.ContainsKey(item.FullName))
                    {
                    }
                    else
                    {
                        classTypeList.Add(item.FullName, item);
                    }
                }
                result.ClassTypeList = classTypeList;
            }
            return(result);
        }