Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. public TypeInfo SecondTry(string commandName)
  2.         {
  3.             TypeInfo type = null;
  4.             Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
  5.             foreach (var item in assemblies)
  6.             {
  7.                 var result = item.GetType().GetTypeInfo().Assembly;
  8.                 var searchetResult = result.DefinedTypes.
  9.                     Where(curT => curT.ImplementedInterfaces.
  10.                 Any(i => i == typeof(ICommand))).Where(n => n.Name.ToLower() == commandName.ToLower() + "command").SingleOrDefault();
  11.                 if (searchetResult!=null)
  12.                 {
  13.                     type = searchetResult;
  14.                     break;
  15.                 }                
  16.             }
  17.             return type;    
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement