/// <summary> Called to save a pdu into the database </summary> /// <param name="dataTransaction"></param> /// <param name="logKey"></param> /// <param name="smscServiceId"></param> /// <param name="pduDirectionType"></param> /// <param name="commandLength"></param> /// <param name="commandSet"></param> /// <param name="commandStatus"></param> /// <param name="sequenceNumber"></param> /// <param name="details"></param> /// <param name="pduDataBlocks"></param> /// <returns> long </returns> public static Guid? Insert(DataTransaction dataTransaction, string logKey, int smscServiceId, PduDirectionTypes pduDirectionType, long commandLength, CommandSet commandSet, CommandStatus commandStatus, long sequenceNumber, List<PduPropertyDetail> details, List<byte[]> pduDataBlocks) { Guid? pduHeaderId = null; // Prepare the database call using (DbCommand dbCommand = dataTransaction.GetStoredProcCommand("spSMPP_Pdu_Insert")) { // Prepare the call dataTransaction.AddInParameterString(dbCommand, "LogKey", logKey); dataTransaction.AddInParameterInteger(dbCommand, "SMSCServiceID", smscServiceId); dataTransaction.AddInParameterShort(dbCommand, "Direction", (short) pduDirectionType); dataTransaction.AddInParameterLong(dbCommand, "CommandLength", commandLength); dataTransaction.AddInParameterString(dbCommand, "CommandId", commandSet.ToString()); dataTransaction.AddInParameterString(dbCommand, "CommandStatusId", commandStatus.ToString()); dataTransaction.AddInParameterLong(dbCommand, "SequenceNumber", sequenceNumber); dataTransaction.AddInParameterTable(dbCommand, "PduPropertyDetails", new PduPropertyDetails(details)); dataTransaction.AddInParameterTable(dbCommand, "PduDataBlocks", new SMSCPduDataBlocks(pduDataBlocks)); dataTransaction.AddOutParameterGuid(dbCommand, "PduHeaderId"); dataTransaction.ExecuteNonQuery(dbCommand); pduHeaderId = dataTransaction.GetParameterValueGuid(dbCommand, "PduHeaderId"); } return pduHeaderId; }
public override bool Handle(CommandSet commandSet, string fileName, string argument) { commandSet.Svn("svn_sample") .Url("http://svn.address.com/trunk") .Auth("username", "password") .Tags("tag1","tab2") .WorkingCopy("workongfolder") .Tags("tag1", "tag2") ; commandSet .Build(true, "compileSample") .Dependency("svn_sample") .Tags("tag2", "tab3") .Release() .ProjectPath("/mypathfor.csproj") .CopyTo("publish/%prjName%"); commandSet .CopyTo("publishFolder_or_network_path", "copySample") .Auth("networkPath_username", "networkPath_password") .Dependency("compileSample") .Tags("tag4", "tab5") ; var manager = new SettingManager(); manager.Save(commandSet, fileName, true); return false; }
public override void Modify(int index1, CommandSet commandSet, string resultPath) { Console.WriteLine("For web project(y/n)?"); var readLine = Console.ReadLine(); var msbuild = (MsBuild)commandSet.Commands[index1]; var y = readLine != null && readLine.ToLower().Trim() == "y"; var builder = new MsBuildCommandBuilder(msbuild, y); var working = WorkingFolder ?? Environment.CurrentDirectory; var fileList = Find(working); for (var index = 0; index < fileList.Count; index++) { var file = fileList[index]; Console.WriteLine(index + ":" + file); } Console.WriteLine("Please input the project file. e.g *.csproj or choice menuList"); var cmd = Console.ReadLine(); builder.ProjectPath(cmd); Console.WriteLine( "if you want to copy compiled folder to another place, please input the path, or press enter for noting."); var copyPath = Console.ReadLine(); if (copyPath != null) { builder.CopyTo(copyPath); } }
public CommandSet(Automaton owner, int capacity, bool autoFire, CommandSet pipe) { this.owner = owner; this.capacity = capacity; this.queue = new List<Command>(); this.pipe = pipe; }
public InGameUser(StageEntity stageEntity, Status.Handle onGoldChanged, TimedConsumableCommandSet.Handle onChargedAttack) { status = new Status<User>(null, null); actionHandler = new ActionHandler(status); status.InitMinMaxVal(User.Gold, 0, stageEntity.maxGold, 0); status.InitMinMaxVal(User.Exp, 0, stageEntity.maxEXP, 0); status.InitMinMaxVal(User.Key, 0, stageEntity.maxKey, 0); AddAction(Action.E_Type.Money, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(User.Gold, value); } ); AddAction(Action.E_Type.GetKey, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(User.Key, value); } ); AddAction(Action.E_Type.Exp, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(User.Exp, value); } ); status.RegisterOnChangeEvent(User.Gold, onGoldChanged); commandQueue = new TimedConsumableCommandSet(null, 100, false, null, onChargedAttack); }
public InGameUser(StageEntity2 stageEntity, Status.Handle onGoldChanged, TimedConsumableCommandSet.Handle onChargedAttack) { this.stat = new Stat<PlayerStatType>(StatGenerator.ExportData<PlayerStatType>(stageEntity, new StatConstants())); this.status = new Status<PlayerStatusType>(null, stat); status.InitMinMaxVal(PlayerStatusType.exp, 0, PlayerStatType.maxEXP, 0); status.InitMinMaxVal(PlayerStatusType.gold, 0, PlayerStatType.maxGold, 0); status.InitMinMaxVal(PlayerStatusType.key, 0, PlayerStatType.maxKey, 0); status.InitMinMaxVal(PlayerStatusType.feverPoint, 0, PlayerStatType.maxFeverPoint, 0); /* actionHandler = new ActionHandler(status); AddAction(Action.E_Type.Money, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(PlayerStatusType.gold, value); } ); AddAction(Action.E_Type.Exp, delegate(float value, GameInstance firer, string[] param) { return new ActionHandler.Result(PlayerStatusType.exp, value); } ); */ status.RegisterOnChangeEvent(PlayerStatusType.gold, onGoldChanged); commandQueue = new TimedConsumableCommandSet(100, false, null, onChargedAttack); }
public override Menu Do(CommandSet commandSet, string resultPath) { Console.Clear(); foreach (var a in Settings.Values) { Console.WriteLine("[{0}] {1}", a.Key, a.Description); } Console.WriteLine("Press exit for exit and press back to back to parent menus."); while (true) { var cmd = Console.ReadLine().ToLower(); if (cmd == "exit") { return Menu.ExitSaveOrNot; } if (cmd == "parent") { return Parent; } if (Settings.ContainsKey(cmd)) { return Settings[cmd]; } Console.WriteLine("Not Recongiaze Cmd."); } }
public void TestMethod1() { var executeSetting = new ExecuteSetting("./"); executeSetting.ForWidnow(); var commandSet = new CommandSet(executeSetting); commandSet.Svn("svn_sample") .Url("http://svn.address.com/trunk") .Auth("username", "password") .Tags("tag1", "tab2") .WorkingCopy("workongfolder") .Tags("tag1", "tag2"); var manager = new SettingManager(); manager.Save(commandSet, "svn.ini", true); Assert.IsTrue(File.Exists("svn.ini")); var target = new CommandSet(new ExecuteSetting("./")); manager.ReadSetting(target, "svn.ini"); var setting = (SvnSetting)target.Settings.First(); Assert.AreEqual("http://svn.address.com/trunk", setting.Url); Assert.AreEqual("username", setting.UserName); Assert.AreEqual("password", setting.Password); Assert.AreEqual("tag1,tag2", String.Join(",", setting.Tags)); Assert.AreEqual("workongfolder", setting.WorkingCopy); Assert.AreEqual("svn_sample", setting.Id); }
public override Menu Do(CommandSet commandSet, string resultPath) { Console.Clear(); Console.WriteLine("Coimmand: <command_key><record index>"); Console.WriteLine("e:Edit, d:Delete, Move-up:u,Move-down:d"); Console.WriteLine("e.g. e0 for edit the first record"); Console.WriteLine(); Console.WriteLine("Command list:"); Console.WriteLine(); for (var i = 0; i < commandSet.Commands.Count; i++) { Console.WriteLine("{0} - {1}", i, commandSet.Commands[i]); } while (true) { var input = Console.ReadLine(); if (input == null) { Console.WriteLine("Error Command!"); continue; } if (input.ToLower() == "exit") break; try { HandleCommand(input, commandSet, resultPath); } catch (Exception ex) { Console.WriteLine("Error Command!"); } } return Parent; }
public void Save(CommandSet commandSet, string filename, bool buildComment = false) { var file = new IniFile(); var isFirst = true; foreach (var setting in commandSet.Settings) { var seciontName = SectionSettingMap.GetSectionName(setting.GetType()); if (!string.IsNullOrEmpty(setting.Id)) { seciontName = seciontName + "_" + setting.Id; } var section = file.Section(seciontName); if (buildComment) { if (isFirst) { section.Comment = BuildFileHeaderDescription(); isFirst = false; } var cus = setting.GetType().GetCustomAttributes(typeof(DescriptionAttribute), true); if (cus.Length > 0) { section.Comment += ((DescriptionAttribute)cus[0]).Description.Replace("\r\n", "\r\n#"); } } SetToSection(section, setting, buildComment); } file.Save(filename); }
public void Can_Execute_Nested_Commands() { var foundNet = false; var foundSend = false; var foundSendArguments = false; var options = new CommandSet() { new CommandArgument("net|--net","{net} performs some network communication and status operations.", v => foundNet = true, new CommandSet() { new CommandArgument("send", "{net send} sends a message to another client on the network", v => { foundSend = true; if (v[0] != null && v[1] != null) foundSendArguments = true; }) })}; var commandLine = "net send * \"Hello everyone!\""; options.Parse(commandLine); Assert.IsTrue(foundNet); Assert.IsTrue(foundSend); Assert.IsTrue(foundSendArguments); }
public void From_complex_un_sortId_and_dependy() { var actual = new List<string>(); var commands = new List<ICommand> { new CommandMock(actual) { Setting = new SettingMock { Id = "1" } }, new CommandMock(actual) { Setting = new SettingMock { Id = "2", } }, new CommandMock(actual) { Setting = new SettingMock { Id = "1-1", Dependency="1" } }, new CommandMock(actual) { Setting = new SettingMock { Id = "3" } }, new CommandMock(actual) { Setting = new SettingMock { Id = "1-1-1", Dependency="1-1" } }, new CommandMock(actual) { Setting = new SettingMock { Id = "1-2", Dependency="1" } } }; var st = new CommandSet(new ExecuteSetting("./"), commands); st.Skip.Add("1"); st.Invoke(); Assert.AreEqual(2, actual.Count); Assert.AreEqual("2", actual[0]); Assert.AreEqual("3", actual[1]); }
public override Menu Do(CommandSet commandSet, string resultPath) { var cmd = CreateCommand(); commandSet.Commands.Add(cmd); if(commandSet.Commands.Count>1) resultPath= Modify(commandSet.Commands.Count - 1, commandSet, resultPath); return Parent; }
protected override ICollection <Command> CreateCollection(IEnumerable <Command> values) { var set = new CommandSet("test"); foreach (var value in values) { set.Add(value); } return(set); }
public override void Modify(int index, CommandSet commandSet, string resultPath) { var vc = (VersionControl)commandSet.Commands[index]; SetUrl(vc); SetWorkingCopy(vc); SetUserName(vc); if (!string.IsNullOrEmpty(vc.UserName)) SetPassword(vc); TryToRun(vc, commandSet); }
public DebuggerApplication(DebuggerModel model, CommandSet commandSet, CommandResultWriterSet commandResultWriterSet) { this.model = model; this.commandSet = commandSet; this.commandResultWriterSet = commandResultWriterSet; list = new ListCommand(commandSet.GetAll()); commandSet.Add(list); commandSet.Add(new HelpCommand(commandSet)); commandSet.Add(new ConnectCommand()); }
private void SetupTestMediator() { m_mediator = new Mediator(); m_mediator.PropertyTable.SetProperty("cache", Cache); m_testWindowConfig = SetupMinimalWindowConfig(); var cmdSet = new CommandSet(m_mediator); cmdSet.Init(m_testWindowConfig); m_mediator.Initialize(cmdSet); }
public override bool Handle(CommandSet set, string fileName, string argument) { var f = argument.Split(':'); if (f.Length == 1) return true; var commandNames = f[1].Split(new[] { ';', ',' }); set.IncludeTags.AddRange(commandNames); return true; }
protected override bool PrepareStringThenSend(CommandSet commandSet) { if (!commandSet.CommandPrepared) { commandSet.Command = string.Concat(commandSet.Command, '\r'); commandSet.CommandPrepared = true; } return(base.PrepareStringThenSend(commandSet)); }
// demonstrates how to build a set of command headers for a complex command request static ICommandHeaders GetCommandHeaders() { var crob = new ControlRelayOutputBlock(OperationType.PULSE_ON, TripCloseCode.NUL, false, 1, 100, 100); var ao = new AnalogOutputDouble64(1.37); return(CommandSet.From( CommandHeader.From(IndexedValue.From(crob, 0)), CommandHeader.From(IndexedValue.From(ao, 1)) )); }
protected IndexCommand( CommandSet commandSet, string name, string?help) : base( commandSet, name, help) { }
private int Execute(CommandSet optionSet) { optionSet.showHelp = false; if (optionSet.help == null) { optionSet.help = new HelpCommand(); optionSet.AddCommand(optionSet.help); } void SetHelp(string v) => optionSet.showHelp = v != null; if (!optionSet.Options.Contains("help")) { optionSet.Options.Add("help", "", SetHelp, hidden: true); } if (!optionSet.Options.Contains("?")) { optionSet.Options.Add("?", "", SetHelp, hidden: true); } var extra = optionSet.Options.Parse(_args); if (extra.Count == 0) { if (optionSet.showHelp) { return(optionSet.help.Invoke(extra)); } return(0); } var command = optionSet.GetCommand(extra); if (command == null) { optionSet.help.WriteUnknownCommand(extra[0]); return(1); } if (optionSet.showHelp) { if (command.Options == null || command.Options.Contains("help")) { extra.Add("--help"); return(command.Invoke(extra)); } command.Options.WriteOptionDescriptions(Console.Out); return(0); } return(command.Invoke(extra)); }
public void Can_Match_Command_Regardless_Of_Case() { var setFinished = false; var options = new CommandSet( new[]{ new CommandArgument("help|--help","Used to display help information", v => setFinished = !setFinished) }); options.Parse("HELP"); Assert.IsTrue(setFinished); //This should have been set to true by the lamba expression }
static int Main(string[] args) { CommandSet suite = null; suite = new CommandSet("AppXtivate") { "usage: suite-name COMMAND [OPTIONS]+", RunCommand() }; return(suite.Run(args)); }
public void LoadCommands(object instance) { if (!_plugins.Contains(instance)) { _plugins.Add(instance); } LoadCommands(instance.GetType()); Commands = GenerateCommandSet(_pluginCommands.Keys.ToArray()); DebugPrintCommands(); }
/// <summary> Constructor </summary> /// <param name="commandSet"></param> /// <param name="commandStatus"></param> /// <param name="sequence"></param> /// <param name="defaultEncoding"></param> public Header(DataCodings defaultEncoding, CommandSet commandSet, CommandStatus commandStatus, uint sequence) { DefaultEncoding = defaultEncoding; PduData = null; Length = HEADER_LENGTH; Command = commandSet; Status = commandStatus; Sequence = sequence; }
static async Task Main(string[] args) { if (args.Length < 1) { throw new ArgumentOutOfRangeException("args", "You must use at least one argument"); } //if (args.Length > 3) // throw new ArgumentOutOfRangeException("args", "Too much arguments"); var commandSet = new CommandSet(args) { { "-?|--help|-h", "Show help information", () => _showHelp = true }, { "init|-i", "Set an unique identifier", (Guid _) => { UniqueId = _; Console.WriteLine(UniqueId); } }, { "set|-s", "Set a key value pair", (IEnumerable <string> _) => { _.ToList().ForEach(Console.WriteLine); } }, { "remove|-r", "Remove a key value pair", (string _) => { Console.WriteLine(_); } }, { "clear|-clr", "Clear the screen", Console.Clear } }; commandSet.Execute(); if (_showHelp) { ShowHelp(commandSet); } Console.ReadLine(); }
public void LoadCommands(CommandSet commandSet) { _availableCommandSet = commandSet; /*ThreadPool.QueueUserWorkItem(o => * { * Debug.WriteLine($"Saving commands!"); * File.WriteAllText("commands.json", JsonConvert.SerializeObject(commandSet, Formatting.Indented)); * //Log.Info($"Commands: {JsonConvert.SerializeObject(commandSet, Formatting.Indented)}"); * });*/ }
/// <summary> Constructor </summary> /// <param name="commandSet"></param> /// <param name="sequence"></param> /// <param name="defaultEncoding"></param> public Header(DataCodings defaultEncoding, CommandSet commandSet, uint sequence) { DefaultEncoding = defaultEncoding; PduData = null; Length = HEADER_LENGTH; Command = commandSet; Status = CommandStatus.ESME_ROK; Sequence = sequence; }
public OrbitVisibilityController(Configuration configuration) { m_configuration = configuration; m_configuration.PropertyChanged += OnConfigurationChanged; m_vesselFilter = new VesselFilter(); m_celestialBodyFilter = new CelestialBodyFilter(); m_hideOrbitCommands = new CommandSet(); IsVisible = true; }
public override void mod(IModable modable) { CommandSet modCommand = modable as CommandSet; if (modCommand == null) { Debug.LogError("Type mismatch"); return; } mod(modCommand); }
public bool ExecuteCommand(CommandSet command, List <string> commandParameters) { return(command switch { CommandSet.create_product => CreateProduct(commandParameters), CommandSet.get_product_info => GetProductInfo(commandParameters), CommandSet.create_order => CreateOrder(commandParameters), CommandSet.create_campaign => CreateCampaign(commandParameters), CommandSet.get_campaign_info => GetCampaignInfo(commandParameters), CommandSet.increase_time => IncreaseTime(commandParameters), _ => false, });
/// <summary> Called to create a BindSmResp object </summary> /// <param name="defaultEncoding"></param> /// <param name="bindSm"></param> /// <param name="commandSet"></param> /// <param name="commandStatus"></param> /// <param name="systemId"></param> /// <returns> BindSmResp </returns> public static BindSmResp Create(DataCodings defaultEncoding, BindSm bindSm, CommandSet commandSet, CommandStatus commandStatus, string systemId) { return(new BindSmResp(defaultEncoding, commandSet, commandStatus, bindSm.Sequence, systemId)); }
/// <summary> /// 获取自定义仓储 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="commandSet"></param> /// <returns></returns> public static IBaseRepository <T> GetRepository <T>(this CommandSet <T> commandSet) { //从基础querySet对象中取出连接对象和提供方 var options = new RepositoryOptionsBuilder(); options.BuildConnection(x => commandSet.DbCon); options.BuildProvider(commandSet.SqlProvider); //设置给通用仓储 var baseRepository = new BaseRepositoryExtension <T>(options); return(baseRepository); }
public void CommandFactory_NullCommandSet() { CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInputs("3"); commandFactory.AddInputs("10 22"); commandFactory.AddInputs("E -1"); CommandSet commandSet = commandFactory.GetCommandSet(); Assert.IsNull(commandSet); }
/// <summary> Constructor </summary> /// <param name="commandSet"></param> /// <param name="commandStatus"></param> /// <param name="defaultEncoding"></param> public Header(DataCodings defaultEncoding, CommandSet commandSet, CommandStatus commandStatus) { DefaultEncoding = defaultEncoding; PduData = null; ExternalId = null; Length = HEADER_LENGTH; Command = commandSet; Status = commandStatus; Sequence = 0; }
/// <returns>If the GUI should run or not.</returns> public static async Task <bool> ExecuteCommandsAsync(string[] args) { var showVersion = false; Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt")); var suite = new CommandSet("wassabee", _output, _error) { "Usage: wassabee [OPTIONS]+", "Launches Wasabi Wallet.", "", { "v|version", "Displays Wasabi version and exit.", x => showVersion = x != null }, { "d|datadir=", "Directory path where store all the Wasabi data.", x => { Global.SetDataDir(x); Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt")); } }, "", "Available commands are:", "", _mixerCommand, _passwordFinderCommand }; EnsureBackwardCompatibilityWithOldParameters(ref args); var commandProccessed = await suite.RunAsync(args) == 0; if (suite.ShowHelp) { return(false); // do not run GUI } else if (showVersion) { ShowVersion(); return(false); // do not run GUI } // if no command was provide we have to lunch the GUI if (!commandProccessed) { var nonProcessedOptions = suite.Options.Parse(args); // If there is some unprocessed argument then something was wrong. if (nonProcessedOptions.Any()) { return(false); } return(true); // run GUI } return(false); }
public void Show() { if (IsVisible) { return; } Logger.Debug("Showing orbits"); m_hideOrbitCommands.Undo(); m_hideOrbitCommands = new CommandSet(); IsVisible = true; OnVisibilityChanged?.Invoke(true); }
/// <summary> /// Creates a new <see cref="OpenPlayer"/> instance. /// </summary> /// <param name="server">The server instance the player connected through</param> /// <param name="endPoint">The player's remote endpoint</param> /// <param name="api">An instance of the API</param> public OpenPlayer(OpenServer server, IPEndPoint endPoint, OpenApi api) : base(server, endPoint) { EnableCommands = true; _plugin = api; IsFlying = false; Permissions = new PermissionManager(); Inventory = new OpenPlayerInventory(this); _serverHaveResources = api.ResourcePackProvider.HasData; Commands = _plugin.CommandManager.GenerateCommandSet(this); //if (Config.GetProperty("useResourcePack")) }
public override PackagedCommands <TVisualizer> NextCommand(double newTime) { if (DongUtility.FileUtilities.IsEndOfFile(br)) { return(null); } var commands = new CommandSet <TVisualizer>(br, factory); var graphData = graphInterface.GetData(); double time = br.ReadDouble(); shouldContinue = br.ReadBoolean(); return(new PackagedCommands <TVisualizer>(commands, graphData, time)); }
public static void Main(string[] args) { JSON.SetDefaultOptions(Options.PrettyPrintCamelCase); var cmds = new CommandSet("EncryptedConfig") { new KeyCommand(), new EncryptCommand(), new DecryptCommand() }; cmds.Run(args); }
public static int Main(string[] args) { var commands = new CommandSet("RolloutScorer") { "usage: RolloutScorer COMMAND [OPTIONS]", "", "Available commands:", new ScoreCommand(), new UploadCommand(), }; return(commands.Run(args)); }
public void Can_Find_Valid_Match_With_Multiple_Signatures() { var setFinished = false; var options = new CommandSet( new []{ new CommandArgument("help|--help","Used to display help information", v => setFinished = !setFinished) }); options.Parse("help"); Assert.IsTrue(setFinished); //This should have been set to true by the lamba expression options.Parse("--help"); Assert.IsFalse(setFinished); //Should have been set to "false" when the options found it ;) }
void OnEnable() { _composition = target as CommandSet; _customCommandsList.Setup(_composition.CustomCommands) .MakeRemovable(_removeCommandButton, Remove) .MakeDrawable(Draw) .MakeHeaderButton(_addExpressionCommandButton, new AddPopup(new AddExpressionContent(this), _addCustomCommandLabel), Color.white) .MakeCollapsable(typeof(CommandSet).Name + "." + nameof(CommandSet.CustomCommands) + ".IsOpen") .MakeEmptyLabel(_customCommandsEmptyLabel) .MakeReorderable() .MakeCustomHeight(GetCommandHeight); }
public void CreateRobot_RoboCreation() { CommandFactory commandFactory = new CommandFactory(); commandFactory.AddInputs("0"); commandFactory.AddInputs("0 0"); CommandSet commandSet = commandFactory.GetCommandSet(); Robot robot = new Robot(commandSet, null); Assert.IsNotNull(robot); }
public void CommandFactory_AddInCompleteInputs_NullCommandSet() { //arrange CommandFactory commandFactory = new CommandFactory(); //act commandFactory.AddInput("5"); commandFactory.AddInput("10 22"); commandFactory.AddInput("E -3"); CommandSet commandSet = commandFactory.GetCommandSet(); //assert Assert.IsNull(commandSet); }
private Command GetCommand(CommandSet commands, string commandName) { Command command; if (commands.ContainsKey(commandName)) { command = commands[commandName]; } else { command = commands.Values.FirstOrDefault(cmd => cmd.Versions.Any(version => version.Aliases != null && version.Aliases.Any(s => s == commandName))); } return(command); }
/// <summary> /// Serialize DVT Detail Data to Xml. /// </summary> /// <param name="streamWriter">Stream writer to serialize to.</param> /// <param name="level">Recursion level. 0 = Top.</param> /// <returns>bool - success/failure</returns> public virtual bool DvtDetailToXml(StreamWriter streamWriter, int level) { if (this._CommandSet != null) { streamWriter.WriteLine("<CommandSetRefId>{0}</CommandSetRefId>", CommandSetRefId); CommandSet.DvtDetailToXml(streamWriter, level); } if (this._DataSet != null) { streamWriter.WriteLine("<DataSetRefId>{0}</DataSetRefId>", DataSetRefId); DataSet.DvtDetailToXml(streamWriter, level); } return(true); }
/// <summary> /// save to exist file. /// </summary> /// <param name="file"></param> /// <param name="commandSet"></param> /// <param name="filename"></param> public void Save(IniFile file, CommandSet commandSet, string filename) { foreach (var setting in commandSet.Settings) { var seciontName = SectionSettingMap.GetSectionName(setting.GetType()); if (!string.IsNullOrEmpty(setting.Id)) { seciontName = seciontName + "_" + setting.Id; } var s = file.Section(seciontName); SetToSection(s, setting, false); } file.Save(filename); }
/// <summary> /// </summary> /// <param name="keies"></param> /// <param name="set"></param> /// <param name="fileName"></param> /// <returns></returns> public bool Handle(IEnumerable<string> keies, CommandSet set, string fileName) { foreach (var key in keies) { var paramName = Regex.Match(key, "[A-z0-9]*").Value; if (_creator.ContainsKey(paramName)) { var goOn = _creator[paramName].Handle(set, fileName, key); if (!goOn) { return false; } } } return true; }
public override bool Handle(CommandSet set, string fileName, string argument) { Console.WriteLine("releaseIt [fileName] for run."); Console.WriteLine(); Console.WriteLine("/skip:commandName;commandName for skip command"); Console.WriteLine("/run:commandName;commandName run following command."); Console.WriteLine("/tags:tag1;tag2 for run"); Console.WriteLine("/skiptag:tag;tag2; to skip"); Console.WriteLine("/c [fileName] to create a template setting file."); Console.WriteLine("e.g. releaseIt setting.ini /t"); return false; }
public ConsoleResponder(Action<string> sendAllMethod) { _sendAllMethod = sendAllMethod; _commands = new CommandSet() { new CommandArgument("echo|-e|--echo","Echoes a simple response back from the server. Sample usage:\n\t\t\t" + "$echo \"Hi!\"\n\t\t\t" + "Server: \"Hi!\"", v => _response = Echo(v.FirstOrDefault())), new CommandArgument("help|-h|--help","{help} explains all of the available commands. " + "Can be used at the end of each individual command (--help) for command-specific instructions.", v => _session.SendResponseAsync(Help().Serialize())), new CommandArgument("net|--net","{net} performs some network communication and status operations.", v => {}, //No-op for good ole' net new CommandSet() { new CommandArgument("send", "{net send} sends a message to another client on the network", v => NetSend(v[0],v[1])) }) }; }
public IniFile ReadSetting(CommandSet commandSet, string filename) { var file = new IniFile(filename); foreach (var section in file.Sections) { var sectionName = section.Name; var ary = sectionName.Split('_'); sectionName = ary[0]; var name = ary.Length > 1 ? string.Join("_", ary, 1, ary.Length - 1) : null; var setting = SectionSettingMap.Create(sectionName); setting.Id = name; FillProperities(setting, section); var command = CommandSettingMap.Create(setting); commandSet.Add(command); } return file; }
/// <summary> /// Constructor. /// /// Use this constructor to construct the command set and data set based on the /// command set and data set contained in the encapsulated DvtkData DicomMessage. /// </summary> /// <param name="dvtkDataDicomMessage">The encapsulated DvtkData DicomMessage.</param> internal DicomMessage(DvtkData.Dimse.DicomMessage dvtkDataDicomMessage) { // Sanity check. if (dvtkDataDicomMessage == null) { DvtkHighLevelInterfaceException.Throw("Parameter may not be null."); } // Create the CommandSet object. this.commandSet = new CommandSet(dvtkDataDicomMessage.CommandSet); // Create the DataSet object. if (dvtkDataDicomMessage.DataSet == null) { this.dataSet = new DataSet(); } else { this.dataSet = new DataSet(dvtkDataDicomMessage.DataSet); } }
public DCPRetCodes AnswerToDCPMessage(DataBuffer a_data, MessageTypes a_msgType, CommandSet a_cmdSet, DCPFrame a_txMsg, DCPFrame a_rxMsg) { DataBuffer buffer = new DataBuffer(a_data.NumItems + 4); byte num = (byte) a_msgType; buffer = a_data; switch (num) { case 0x40: case 0x80: a_txMsg.CmdSet = (byte) a_cmdSet; a_txMsg.SeqNum = a_rxMsg.SeqNum; break; } int num2 = 0; while (num2 < _DCPMsgRepeatNr) { DCPRetCodes codes; if (_dcpVersion == DCPVersion.DCP) { codes = a_txMsg.ConstructDCPmsg(buffer, a_cmdSet, a_msgType); } else { codes = a_txMsg.ConstructDCP2msg(buffer, a_cmdSet, a_msgType); } codes = doExchangeDCP_TX(a_txMsg, a_rxMsg); switch (codes) { case DCPRetCodes.DCP_RESP_SENT: return codes; case DCPRetCodes.DCP_FATAL: return codes; } return DCPRetCodes.DCP_FATAL; } return DCPRetCodes.DCP_FATAL; }
public override void Modify(int index, CommandSet commandSet, string resultPath) { var result = (XCopy)commandSet.Commands[index]; while (string.IsNullOrEmpty(result.TargetPath)) { Console.WriteLine("Input target path."); result.TargetPath = Console.ReadLine(); } while (true) { try { Console.WriteLine("1. Full Copy, 2.Base on copy Date Y-M-D?"); var choice = Convert.ToInt32(Console.ReadLine()); result.UserDateCompareCopy = choice == 2; break; } catch (Exception) { // ignored } } }
private void HandleCommand(string input, CommandSet commandSet, string resultPath) { var cmd = input.Substring(0, 1); var index = Convert.ToInt32(input.Substring(1)); if (cmd == "e") { Modify(index, commandSet, resultPath); return; } if (cmd == "u") { Up(index, commandSet); } if (cmd == "d") { var target = index++; if (target != 0) { Down(index, commandSet); } } }
public CommandSet AddCommandSet(string name, int capacity, bool autoFire, E_CommandConsume consumeType, CommandSet pipe) { CommandSet ret = null; if (consumeType == E_CommandConsume.ItemSlot) { ret = new ItemSlot(name, pipe); } else if (consumeType == E_CommandConsume.None) { ret = new ConsumableCommandSet(capacity, autoFire, false, pipe); } else if (consumeType == E_CommandConsume.Skill) { ret = new SkillSlot(pipe); } if (ret != null) { commandQueue.Add(name, ret); } return ret; }
public void SetQueue(CommandSet blockQueue) { this.blockQueue = blockQueue; }