本文整理汇总了C#中Command.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Command.ToString方法的具体用法?C# Command.ToString怎么用?C# Command.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handleCommand
void handleCommand(string text)
{
if(Command.isCommand(text)){
Command cmd = new Command(text);
Write(cmd.ToString());
switch(cmd.Main){
case "server":
//networkHandler.handleNetworkCommand(cmd);
break;
case "console":
HandleConsoleCommand(cmd);
break;
case "exit":
Write (">exiting");
TCPHandler.getInstance().stop();
Application.Quit();
break;
case "spawn":
//PlayerEvents.fireOnCreatePlayer("qwe");
break;
case "session":
// PlayerEvents.fireOnCreatePlayer("qwe");
SessionModule.HandleCommand(cmd);
break;
default:
Write("chat");
//networkHandler.handleChat(text);
break;
}
}
}
示例2: media_upload
//TODO: Update response object
public static async Task<Upload> media_upload(this Api api, Command command, long total_bytes, string media_data = "", byte[] media = null, string media_type = "", long media_id = -1, int segment_index = 0, IEnumerable<string> additional_owners = null)
{
var uri = "https://upload.twitter.com/1.1/media/upload.json";
var client = new HttpClient(new MessageHandler(api.Token));
var request = new HttpRequestMessage(HttpMethod.Post, uri);
var content = new MultipartFormDataContent();
content.Add(new StringContent(command.ToString()), "command");
if (media_id != -1) content.Add(new StringContent(media_id.ToString()), "media_id");
if (segment_index != 0) content.Add(new StringContent(segment_index.ToString()), "segment_index");
if (!string.IsNullOrEmpty(media_type)) content.Add(new StringContent(media_type), "media_type");
if (total_bytes != -1) content.Add(new StringContent(total_bytes.ToString()), "total_bytes");
if (!string.IsNullOrEmpty(media_data)) content.Add(new StringContent(media_data), "media_data");
if (media != null) content.Add(new ByteArrayContent(media), "media");
if (additional_owners != null && additional_owners.Any())
{
content.Add(new StringContent(string.Join(",", additional_owners)), "additional_owners");
}
request.Content = content;
var response = await client.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<Upload>(json);
return result;
}
示例3: SendMessage
public static bool SendMessage(Command cmd)
{
try
{
using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", PipeServer.SERVERNAME, PipeDirection.InOut))
{
// Connect to the pipe or wait until the pipe is available.
Log.Write("Attempting to connect to pipe: " + PipeServer.SERVERNAME);
pipeClient.Connect(1000);
Log.Write("Connected to pipe.");
StreamWriter sw = new StreamWriter(pipeClient);
{
sw.AutoFlush = true;
sw.WriteLine(cmd.ToString());
pipeClient.WaitForPipeDrain();
Log.Write("Pipe Message Sent: " + cmd.ToString());
}
StreamReader sr = new StreamReader(pipeClient);
{
string temp;
while ((temp = sr.ReadLine()) != null)
{
Log.Write("Pipe Message Received: " + temp);
if (temp == "done")
return true;
else if (temp == "failed")
return false;
}
}
sw.Close();
sr.Close();
}
}
catch (Exception exc)
{
Log.Write(exc.ToString(), true);
return false;
}
return false;
}
示例4: ToString_CreateNewInvalidCommandWithWrongName
public void ToString_CreateNewInvalidCommandWithWrongName()
{
ICommand newCommand = new Command("Add application: Firefox v.11.0; Mozilla; 16148072; http://www.mozilla.org");
string commandAsString = newCommand.ToString();
string expectedString = "Add application Firefox v.11.0 Mozilla 16148072 http://www.mozilla.org";
Assert.AreEqual(expectedString, commandAsString);
}
示例5: Do
public static void Do(Command cmd, string path,params TortoiseParameter[] parameters)
{
var add = "";
foreach (var p in parameters)
{
if (add != "") add += " ";
add += "/" + p.Name + ":" + p.Value;
}
CSRunner.RunExecutable(Config.Get.TortoiseProc, "/command:" + cmd.ToString().ToLower() + " /path:\"" + path + "\" " + add ,false);
}
示例6: AddCommand
public void AddCommand(Token token, Command command)
{
this.Context.Application.Lock();
Commands commands = (Commands)this.Context.Application["Commands"];
this.Context.Application.UnLock();
//Do AddCommand
commands.Add(token, command);
//Log
string isDebug = System.Configuration.ConfigurationSettings.AppSettings["IsDebug"];
if (isDebug != null && Convert.ToBoolean(isDebug))
{
string logCommands = System.Configuration.ConfigurationSettings.AppSettings["LogCommands"];
if (logCommands != null && (logCommands == "*" || logCommands.IndexOf(command.GetType().Name) > -1))
{
iExchange.Common.AppDebug.LogEvent("DealingConsole.Service2.AddCommand", token.ToString() + "\n" + command.ToString(), System.Diagnostics.EventLogEntryType.Warning);
}
}
}
示例7: ParseCommandLine
//.........这里部分代码省略.........
detached = true;
break;
case "?":
goto default;
default:
throw new UsageException();
}
}
else {
fileNames.Clear();
fileNames.Add(arg);
argState = ArgStates.FileName;
}
break;
case ArgStates.Location:
switch (arg.ToUpperInvariant()) {
case "CU":
storeLocation = StoreLocation.CurrentUser;
break;
case "LM":
storeLocation = StoreLocation.LocalMachine;
break;
default:
throw new UsageException();
}
argState = ArgStates.Options;
break;
case ArgStates.Password:
password = arg;
argState = ArgStates.Options;
break;
case ArgStates.SHA1:
sha1 = arg;
argState = ArgStates.Options;
break;
case ArgStates.Subject:
subjects.Add(arg);
argState = ArgStates.Options;
break;
case ArgStates.Issuer:
issuers.Add(arg);
argState = ArgStates.Options;
break;
case ArgStates.PFX:
pfxFile = arg;
argState = ArgStates.Options;
break;
case ArgStates.Include:
try {
includeOptions.Add((IncludeOptions) Convert.ToInt32(arg));
}
catch (FormatException) {
throw new UsageException();
}
argState = ArgStates.Options;
break;
case ArgStates.FileName:
if (arg.Substring(0, 1) == "-" || arg.Substring(0, 1) == "/")
throw new UsageException();
fileNames.Add(arg);
break;
default:
throw new InternalException("Internal error: Unknown argument state (argState = " + argState.ToString() + ").");
}
}
// Make sure we are in good state.
if (argState != ArgStates.FileName)
throw new UsageException();
// Make sure all required options are valid.
// Note: As stated in the help screen, non-fatal invalid options for
// the specific command is ignore. You can add the logic here
// to further handle these invalid options if desired.
switch (command)
{
case Command.Sign:
// -l and -pfxFile are exclusive.
if (null != pfxFile) {
if (storeLocationSpecified)
throw new UsageException();
}
break;
case Command.Verify:
break;
default:
throw new InternalException("Internal error: Unknown command state (Command = " + command.ToString() + ").");
}
}
示例8: Execute
public static List<Point> Execute(Command command, string mainPattern, string extraPattern, float similarity, int timeout)
{
ProcessStartInfo psi = null;
string output = "";
string error = "";
try
{
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
AddSikuliLibs();
if (String.IsNullOrEmpty(extraPattern))
{
psi = new ProcessStartInfo("java.exe", "-jar" + AddQuotes(Path.GetDirectoryName(typeof(Commander).Assembly.Location) + @"\" + Settings.JarFile) + AddQuotes(mainPattern) + AddQuotes(command.ToString()) + " " + similarity + " " + timeout);
}
else
{
psi = new ProcessStartInfo("java.exe", "-jar" + AddQuotes(Path.GetDirectoryName(typeof(Commander).Assembly.Location) + @"\" + Settings.JarFile) + AddQuotes(mainPattern) + AddQuotes(command.ToString()) + " " + similarity + " " + timeout + AddQuotes(extraPattern));
}
System.IO.File.WriteAllText(@"C:\SikuliOutputLog.txt", psi.Arguments);
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
System.Diagnostics.Process reg;
reg = System.Diagnostics.Process.Start(psi);
reg.WaitForExit();
using (System.IO.StreamReader myOutput = reg.StandardOutput)
{
output = myOutput.ReadToEnd();
}
using (System.IO.StreamReader myError = reg.StandardError)
{
error = myError.ReadToEnd();
}
ConsumeResult(output, error);
switch (command)
{
case Command.FIND_ALL:
case Command.EXISTS:
{
return PrepareCoordinates(output);
}
default:
{
return null;
}
}
}
catch (Exception ex)
{
System.IO.File.WriteAllText(@"C:\SikuliExceptionLog.txt", ex.Message);
}
return null;
}
示例9: HandleCmd
private async Task HandleCmd(Command cmd)
{
try
{
await HandleCommand(this, cmd._prefix, cmd._command, cmd._parameters.ToArray());
}
catch (IrcException e)
{
OnUnhandledException(e);
}
catch (Exception e)
{
OnUnhandledException(new IrcException("An error occured during handling of message " + cmd.ToString(), e));
}
}
示例10: Oneway
public void Oneway(Command command)
{
Tracer.Debug("MockTransport sending oneway Command: " + command.ToString());
if(command.IsMessage)
{
this.numSentMessages++;
if(this.failOnSendMessage && this.numSentMessages > this.numSentMessagesBeforeFail)
{
Tracer.Debug("MockTransport Oneway send, failing as per configuration.");
throw new IOException("Failed to Send Message.");
}
}
if(command.IsKeepAliveInfo)
{
this.numSentKeppAliveInfos++;
if(this.failOnKeepAliveInfoSends && this.numSentKeppAliveInfos > this.numSentKeepAliveInfosBeforeFail)
{
Tracer.Debug("MockTransport Oneway send, failing as per configuration.");
throw new IOException("Failed to Send Message.");
}
}
// Process and send any new Commands back.
List<Command> results = new List<Command>();
// Let the Response Builder give us the Commands to send to the Client App.
if(command.IsMessage)
{
if(this.respondToMessages && this.NumMessagesToRespondTo < this.numMessagesRespondedTo)
{
results = this.responseBuilder.BuildIncomingCommands(command);
this.numMessagesRespondedTo++;
}
}
else
{
results = this.responseBuilder.BuildIncomingCommands(command);
}
lock(this.receiveQueue)
{
foreach(Command result in results)
{
this.receiveQueue.Enqueue(result);
}
}
this.asyncResponseTask.Wakeup();
// Send the Command to the Outgoing Command Snoop Hook.
if(this.OutgoingCommand != null)
{
Tracer.Debug("MockTransport Oneway, Notifying Outgoing linstener.");
this.OutgoingCommand(this, command);
}
}
示例11: Request
public Response Request(Command command, TimeSpan timeout)
{
Tracer.Debug("MockTransport sending Request Command: " + command.ToString());
if(command.IsMessage)
{
this.numSentMessages++;
if(this.failOnSendMessage && this.numSentMessages > this.numSentMessagesBeforeFail)
{
throw new IOException("Failed to Send Message.");
}
}
// Notify external Client of command that we "sent"
if(this.OutgoingCommand != null)
{
this.OutgoingCommand(this, command);
}
command.CommandId = Interlocked.Increment(ref this.nextCommandId);
command.ResponseRequired = true;
return this.responseBuilder.BuildResponse(command);
}
示例12: produce
public void produce(Command command)
{
if(command.GetType().IsSubclassOf(typeof(ModelCommand))){
lock(command){
getCore().consume(command);
if( ! command.isSucceed()){
throw new Exception(command.getCommandSatus().getMessage());
}
try {
Monitor.Wait(command, 12000000);
} catch (Exception e) {
throw new Exception("fail to execute command : "+command.ToString(),e);
}
}
}else{
getCore().consume(command);
}
if( ! command.isSucceed()){
throw new Exception(command.getCommandSatus().getMessage());
}
log.Info("releasing thread command version "+command.getVersion());
}
示例13: ExecuteSpecificCommand
private void ExecuteSpecificCommand(Command command)
{
if (command == Command.Invalid || (!this.isGameStarted && command == Command.Move))
{
throw new ArgumentException("Invalid Command!");
}
string methodName = "Execute" + command.ToString() + "Command";
var methodInfo = this.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
try
{
methodInfo.Invoke(this, null);
}
catch (InvalidOperationException ex)
{
this.renderer.RenderMessage(ex.Message);
}
}
示例14: FormatJsCommand
private static string FormatJsCommand( Command command )
{
var first = command.ToString().ToLower()[ 0 ];
var remainder = command.ToString().Substring( 1 );
return first + remainder;
}
示例15: ProcessCommand
public CommandResult ProcessCommand(Command command)
{
#if DEBUG
TraceSources.ExecutiveSource.TraceEvent(TraceEventType.Information, 0,
"Command:" + command.ToString());
#endif
CommandResult result = null;
if (command is ViewCommand)
{
result = this.view.ProcessCommand(command);
}
else if (command is InsertScopeNodesCommand)
{
result = this.navigator.ProcessCommand(command as InsertScopeNodesCommand);
}
else if (command is DeleteScopeNodesCommand)
{
result = this.navigator.ProcessCommand(command as DeleteScopeNodesCommand);
}
else if (command is UpdateScopeNodeCommand)
{
result = this.navigator.ProcessCommand(command as UpdateScopeNodeCommand);
}
#if DEBUG
TraceSources.ExecutiveSource.TraceEvent(TraceEventType.Information, 0,
"CommandResult:" + (result == null ? "null" : result.ToString()));
#endif
return result;
}