Ejemplo n.º 1
0
 /// <summary>
 /// 根据命令名返回命令
 /// </summary>
 /// <param name="OrderName">命令名</param>
 /// <returns>所查询的命令,如果命令名不存在返回null</returns>
 public static POrder GetOrder(string OrderName)
 {
     foreach (Type SubType in typeof(POrder).Assembly.GetTypes().Where((Type TempType) => TempType.IsSubclassOf(typeof(POrder))))
     {
         try {
             POrder OrderInstance = (POrder)Activator.CreateInstance(SubType);
             if (OrderInstance.Name.Equals(OrderName))
             {
                 return(OrderInstance);
             }
         } catch {
             continue;
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
 public static IEnumerable <Type> ListSubTypes <T>()
 {
     return(typeof(T).Assembly.GetTypes().Where((Type TempType) => TempType.IsSubclassOf(typeof(T))));
 }