本文整理汇总了C#中CommandSet类的典型用法代码示例。如果您正苦于以下问题:C# CommandSet类的具体用法?C# CommandSet怎么用?C# CommandSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandSet类属于命名空间,在下文中一共展示了CommandSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Do
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.");
}
}
示例2: Insert
/// <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;
}
示例3: InGameUser
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);
}
示例4: InGameUser
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);
}
示例5: CommandSet
public CommandSet(Automaton owner, int capacity, bool autoFire, CommandSet pipe)
{
this.owner = owner;
this.capacity = capacity;
this.queue = new List<Command>();
this.pipe = pipe;
}
示例6: TestMethod1
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);
}
示例7: Save
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);
}
示例8: Can_Execute_Nested_Commands
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);
}
示例9: From_complex_un_sortId_and_dependy
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]);
}
示例10: Modify
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);
}
}
示例11: Do
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;
}
示例12: Handle
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;
}
示例13: Do
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;
}
示例14: Handle
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;
}
示例15: Modify
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);
}