//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); }
/// <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[] ts = assembly.GetTypes(); Dictionary <string, string> classList = new Dictionary <string, string>(); Dictionary <string, Type> classTypeList = new Dictionary <string, Type>(); foreach (var item in ts) { if (item.FullName.Contains("Message")) { if (item.Name.Contains("Api") || item.FullName.Contains("+")) { } else { classList.Add(item.Name, item.FullName); } } else { string temp; if (classList.TryGetValue(item.Name, out temp)) { } else { classList.Add(item.Name, item.FullName); classTypeList.Add(item.Name, item); } } } result.ClassTypeList = classTypeList; result.ClassList = classList; } return(result); }