static void Main(string[] args) { Console.WriteLine("Введите комманду и путь. Для справки введите команду help."); var reader = new CommandReader(); reader.Read(); }
private void QueueReadCommand(NamedConnection connection) { lock (_lock) { _runningCommands.Add(Task.Factory.StartNew <CommandRead>(() => { ICommandReader reader = new CommandReader(); MqttCommand cmd = reader.Read(connection.Connection); return(new CommandRead(cmd, connection)); }, TaskCreationOptions.LongRunning)); } }
public void IgnoresUnparseableCommands() { var commands = new string[] { "REPORT", "LEFT", "FFSJKF", "PLACE 0,0,FOO", "RIGHT", }; var results = CommandReader.Read(commands).ToList(); Check.That(results).HasSize(3); }
public IGeneratorRunSyntax ParseCommand(params string[] arguments) { Logger.Trace($"Parse command {string.Join(" ", arguments)}"); this.Modules.OfType <GeneratorModule>().ForEach(x => x.BeforeConfigure()); CommandReader reader = this.resolver.Create <CommandReader>(); this.command = reader.Read(arguments); this.command.Standalone = this.standalone; CommandValueParameter outputParameter = this.command.Parameters.OfType <CommandValueParameter>().FirstOrDefault(x => x.Name.Equals("output", StringComparison.CurrentCultureIgnoreCase)); if (outputParameter != null) { this.SetOutput(outputParameter.Value); } return(this); }
public MainWindow() { _missionProfiles = new Dictionary <string, MissionProfile>(); InitializeComponent(); var profileLoader = new FlightProfileManager(); var profiles = profileLoader.GetAllProfiles(); foreach (string profile in profiles) { string displayName = Path.GetFileNameWithoutExtension(profile); try { var missionProfile = new MissionProfile { Config = MissionConfig.Load(profile), Commands = new Dictionary <string, List <Command> >() }; string[] commandFiles = Directory.GetFiles(profile); // Load all the craft mission commands foreach (string commandFile in commandFiles) { if (commandFile.IndexOf("MissionConfig.xml", StringComparison.InvariantCultureIgnoreCase) > 0 || commandFile.IndexOf("Structures.xml", StringComparison.CurrentCultureIgnoreCase) > 0) { continue; } var commmands = CommandReader.Read(commandFile); missionProfile.Commands.Add(Path.GetFileNameWithoutExtension(commandFile), commmands); } _missionProfiles.Add(displayName, missionProfile); ProfileBox.Items.Add(displayName); } // Swallow exceptions for broken profiles catch { } } }
/// <summary> /// Loads commands from an xml format. /// </summary> public static List <CommandBase> Load(string path) { List <Command> contracts = CommandReader.Read(path); var commands = new List <CommandBase>(); // Not a great way to do this unfortunately... foreach (Command contract in contracts) { if (contract is Ignition) { commands.Add(new IgnitionCommand(contract as Ignition)); } else if (contract is Shutdown) { commands.Add(new ShutdownCommand(contract as Shutdown)); } else if (contract is Throttle) { commands.Add(new ThrottleCommand(contract as Throttle)); } else if (contract is Stage) { commands.Add(new StageCommand(contract as Stage)); } else if (contract is Terminate) { commands.Add(new TerminateCommand(contract as Terminate)); } else if (contract is Release) { commands.Add(new ReleaseCommand(contract as Release)); } else if (contract is Deploy) { commands.Add(new DeployCommand(contract as Deploy)); } else if (contract is Retrograde) { commands.Add(new RetrogradeCommand(contract as Retrograde)); } else if (contract is Prograde) { commands.Add(new ProgradeCommand(contract as Prograde)); } else if (contract is AutoLand) { commands.Add(new AutoLandCommand(contract as AutoLand)); } else if (contract is Cant) { commands.Add(new CantCommand(contract as Cant)); } else if (contract is Dihedral) { commands.Add(new DihedralCommand(contract as Dihedral)); } else if (contract is Pitch) { commands.Add(new PitchCommand(contract as Pitch)); } else if (contract is RelativePitch) { commands.Add(new RelativePitchCommand(contract as RelativePitch)); } else if (contract is Roll) { commands.Add(new RollCommand(contract as Roll)); } else if (contract is Yaw) { commands.Add(new YawCommand(contract as Yaw)); } else if (contract is Post) { commands.Add(new PostCommand(contract as Post)); } else if (contract is Rate) { commands.Add(new RateCommand(contract as Rate)); } else if (contract is Target) { commands.Add(new TargetCommand(contract as Target)); } else if (contract is Zoom) { commands.Add(new ZoomCommand(contract as Zoom)); } } return(commands); }