private static ICommandlineSystem[] GetSystemsTools(Assembly target) { Type[] asmTypes = target .GetTypes().Where( x => typeof(ICommandlineSystem).IsAssignableFrom(x) && !x.IsAbstract && !x.IsInterface ).ToArray(); ICommandlineSystem[] ret = new ICommandlineSystem[asmTypes.Length]; for (int i = 0; i < asmTypes.Length; i++) { Type asmType = asmTypes[i]; ret[i] = (ICommandlineSystem)Activator.CreateInstance(asmType); } return(ret); }
public static void Run(string[] args, string applicationUpdateUrl = null, string systemUpdateUrl = null) { ApplicationUpdateUrl = applicationUpdateUrl; SystemUpdateUrl = systemUpdateUrl; Tools = GetSystemsTools(); if (args.Length != 0) { ICommandlineSystem selected = Tools.FirstOrDefault(x => x.Name == args[0]); selected?.Run(args.Skip(1).ToArray()); } else { Console.WriteLine("Argument Mismatch"); Tools.First(x => x is HelpSystem).Run(new string[0]); } #if DEBUG Console.WriteLine("Press any key to exit.."); Console.ReadLine(); #endif }