protected override List <ValueTuple <int, string> > GetHelpLines() { List <ValueTuple <int, string> > Result = new List <ValueTuple <int, string> >() { (0, "Note: Optional arguments are shown as [argument(s)]"), (0, "Note: [argument(s)]... means; at least one -argument(s)- must be provided; but also you can provide multiple."), (0, "Note: (argument1 or argument2 ...) means; only one of -argument(no)-s must be provided."), (0, "Note: If userId argument is not provided; command will be run for the user logged in."), (0, "\n"), (0, "Settings - commands"), (1, /*_______________________*/ ""), (0, "\n"), (2, "set versionName=\"...\""), (0, "\tAvailable versions: " + string.Join(", ", StringToEnum.Keys)), (2, "set deploymentName=\"...\""), (0, "\n") }; foreach (Type Command in LoadedCommands.Values) { Command_0_1 Cmd = (Command_0_1)Activator.CreateInstance(Command, ""); Result.AddRange(Cmd.GetHelpLines()); } return(Result); }
private int OperateCommands(Arguments _Arguments) { var Invalid_Expected = "Invalid argument. Check -help-"; if (_Arguments.First.Value.ArgumentType != Argument.Type.Unary) { return(Utilities.Error(Invalid_Expected + "; given argument is: " + _Arguments.First.Value.ToString())); } var Current = (_Arguments.First.Value as UnaryArgument).Value; _Arguments.RemoveFirst(); Command_0_1 Command = (Command_0_1)Activator.CreateInstance(LoadedCommands[Current], _Arguments); return(Command.Perform()); }
public static void LoadCommandAssemblies(string[] AssemblyNames) { Arguments.ParseArguments(new string[] { "" }, out Arguments _BlankArg); for (int i = 0; i < AssemblyNames.Length; ++i) { Assembly Asm = Assembly.Load(File.ReadAllBytes(AssemblyNames[i])); Type[] AllTypes = Asm.GetTypes(); for (int t = 0; t < AllTypes.Length; ++t) { if (AllTypes[t].BaseType.FullName == typeof(Command_0_1).FullName) { Type Current = AllTypes[t]; Command_0_1 Instance = (Command_0_1)Activator.CreateInstance(Current, new object[] { _BlankArg }); LoadedCommands.Add(Instance.GetCommandName(), Current); } } } }