public OutputParser(string[] args) : base(args) { Password = ArgsList.ContainsKey(ArgsType.PASSWORD) ? ArgsList[ArgsType.PASSWORD].Parameter : ""; Message = ArgsList.ContainsKey(ArgsType.INPUTCONSOLE) ? ArgsList[ArgsType.INPUTCONSOLE].Parameter : ""; Filein = ArgsList.ContainsKey(ArgsType.INPUTFILE) ? ArgsList[ArgsType.INPUTFILE].Parameter : ""; Fileout = ArgsList.ContainsKey(ArgsType.OUTPUTFILE) ? ArgsList[ArgsType.OUTPUTFILE].Parameter : ""; Mode = ArgsList.ContainsKey(ArgsType.DECRYPT) ? ArgsList[ArgsType.DECRYPT].Arg == ArgsType.DECRYPT ? ArgsType.DECRYPT : ArgsType.ENCRYPT : ArgsType.ENCRYPT; }
public Object OutputClass() { if (ArgsConflict == null & ArgsOoR == null & ToManyArgs == null & ArgsUnknown == null) { if (ArgsList.ContainsKey(ArgsType.HELP)) { return(new HelpInfo()); } else if (ArgsList.ContainsKey(ArgsType.INPUTCONSOLE) & ArgsList.ContainsKey(ArgsType.OUTPUTCONSOLE)) { return(new ConsoleInOut(Message, Password, Mode)); } else if (ArgsList.ContainsKey(ArgsType.INPUTCONSOLE) & ArgsList.ContainsKey(ArgsType.OUTPUTFILE)) { return(new ConsoleInFileOut(Message, Fileout, Password, Mode)); } else if (ArgsList.ContainsKey(ArgsType.INPUTFILE) & ArgsList.ContainsKey(ArgsType.OUTPUTCONSOLE)) { return(new FileInConsoleOut(Filein, Password, Mode)); } else if (ArgsList.ContainsKey(ArgsType.INPUTFILE) & ArgsList.ContainsKey(ArgsType.OUTPUTFILE)) { return(new FileInOut(Filein, Fileout, Password, Mode)); } } else if (ArgsConflict != null) { return(ArgsConflict); } else if (ArgsOoR != null) { return(ArgsOoR); } else if (ToManyArgs != null) { return(ToManyArgs); } return(ArgsUnknown); }
public ErrorParser(string[] args) : base(args) { if (ArgsList.ContainsKey(ArgsType.HELP) ^ !((ArgsList.ContainsKey(ArgsType.INPUTFILE) ^ ArgsList.ContainsKey(ArgsType.INPUTCONSOLE)) & (ArgsList.ContainsKey(ArgsType.ENCRYPT) ^ ArgsList.ContainsKey(ArgsType.DECRYPT)))) { ArgsConflict = new Exception("Противоречие или отсутствие аргументов"); } if (Outofrange) { ArgsOoR = new Exception("Отсутсвие параметров для аргумента или их неявное задание"); } if (UnunknownArg) { ArgsUnknown = new Exception("Присутсвует неизвестный аргумент"); } foreach (ArgsType x in ArgsList.Keys) { if (ArgsList[x].Count > 1) { ToManyArgs = new Exception("Нерациональное количество одинаковых аргументов"); } } }