本文整理汇总了C#中ICommand.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ICommand.ToString方法的具体用法?C# ICommand.ToString怎么用?C# ICommand.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICommand
的用法示例。
在下文中一共展示了ICommand.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RouteToHandler
public void RouteToHandler(ICommand command)
{
//optype set in logger context information about the logical operation that the system is executing
//is used to group log messages togheter and to correlate child log to a logical operation.
_logger.SetOpType("command", command.GetType().FullName + " Id:" + command.Id);
_logger.Info("[queue] processing command " + command.ToString());
var commandType = command.GetType();
//get the executor function from the catalog, and then simply execute the command.
var commandinvoker = _commandHandlerCatalog.GetExecutorFor(commandType);
try
{
commandinvoker.Invoke(command);
_logger.Info("[queue] command handled " + command.ToString());
}
catch (System.Exception ex)
{
//TODO log or do something better instead of retrhowing exception
_logger.Error("[queue] Command error " + ex.Message, ex);
throw;
}
finally
{
_logger.RemoveOpType();
}
}
示例2: ExecuteCommand
public ICommand ExecuteCommand(ICommand command)
{
Stack<ICommand> commandStack = GetCommandStack();
command.Execute();
SubscriptionService.SubscriptionService.NotifyAll(command.ToString());
commandStack.Push(command);
return command;
}
示例3: Dispatch
public void Dispatch(ICommand cmd)
{
if (cmd.Timestamp == DateTime.MinValue)
{
throw new ArgumentException("Command must have a timestamp: " + cmd.GetType());
}
if (this.services.ContainsKey(cmd.GetType()))
{
foreach (var handler in this.services[cmd.GetType()])
{
lock (onecommand)
{
Logger.DebugFormat("Dispatching Command: {0}", cmd.ToString());
handler.Execute(cmd);
}
}
}
else
{
throw new InvalidOperationException(string.Format("No service to execute command {0}", cmd));
}
}
示例4: SendCommand
/// <summary>
/// Sends a command over the network
/// </summary>
/// <param name="command">The command to be sent</param>
/// <param name="process">Should the command data be processed?</param>
public virtual void SendCommand(ICommand command, bool process = true)
{
lock (lockObject)
{
string commandString = command.ToString() + '\n';
if (commandString.Length > 511)
{
throw new CommandTooLongException();
}
if (socket == null)
{
return;
}
OnSendRawData(commandString);
byte[] data = ConnectionEncoding.GetBytes(commandString);
SendData(data);
if (process)
{
OnReceive(commandString, true);
}
}
}
示例5: ExecuteCommand
private void ExecuteCommand(ICommand command)
{
try
{
command.Execute();
}
catch (ThreadAbortException)
{
_logger.DebugFormat("Swallowed ThreadAbortException");
//Swallow. A redirect has happened
}
catch (Exception ex)
{
_logger.WarnFormat(ex, "Failed to execute {0} command", command.ToString());
}
}
示例6: DebugPrintCommand
static void DebugPrintCommand(string prefix, ICommand command)
{
System.Diagnostics.Debugger.Log(0, "CmdHistory",
String.Format("{0}:{1}\n", prefix, command.ToString()));
CommandCollection cq = command as CommandCollection;
if (cq != null)
{
for (int i = 0; i < cq.Count; ++i)
{
System.Diagnostics.Debugger.Log(0, "CmdHistory",
String.Format(" [{0}]:{1}\n", i, cq[i].ToString()));
}
}
}
示例7: SaveEventsOnEventStore
protected override void SaveEventsOnEventStore(ICommand command, EntityId entityId, IEnumerable<IEvent> versionedEvents)
{
var aggregateRootId = command.AggregateRootId;
var eventDescriptors = versionedEvents.Select(evnt => BuildEventDescriptor(command.CommandId, entityId, evnt));
CommandDescriptorsFor(aggregateRootId).Add(new CommandDescriptor(command.CommandId, aggregateRootId, command.Created, AggregateRootType(aggregateRootId), CommandType(command), command.ToString()));
EventDescriptorsForEntity(entityId).AddRange(eventDescriptors);
}
示例8: UnregisterCommand
public override void UnregisterCommand(ICommand command)
{
StackFrame frame = new StackFrame(skipFrames);
var method = frame.GetMethod();
var type = method.DeclaringType;
var name = method.Name;
var c = command.ToString();
var key = string.Format("{0}.{1} -> {2}", type.Name, name, Label);
Registrations.remove(key);
base.UnregisterCommand(command);
}
示例9: RunCommand
void RunCommand(ICommand command)
{
_serviceClient.CommandClient.ExecuteCommand(command);
_commandStack.Push(command);
ToolStripMenuItem undoCommandMenuItem = new ToolStripMenuItem(command.ToString());
undoToolStripMenuItem.DropDownItems.Add(undoCommandMenuItem);
//undoToolStripMenuItem.Click += (s, e) =>
// {
// UndoCommand();
// undoToolStripMenuItem.DropDownItems.RemoveAt(undoToolStripMenuItem.DropDownItems.Count-1);
// };
}