Example #1
0
        public async Task <IHttpActionResult> PostAsync([FromBody] ICommand command)
        {
            return(await ActionHelper.TryCatchWithLoggerAsync(async() =>
            {
                _logger.WriteDebug(new LogMessage(string.Concat("VecompSoftware.DocSuiteWeb.WebAPI.Controllers.ServiceBus.QueueController.PostAsync(", command != null, ")")), LogCategories);

                if (command == null)
                {
                    _logger.WriteWarning(new LogMessage(string.Concat("Command received is invalid (json deserialization set null value) : ",
                                                                      GetType().ToString())), LogCategories);

                    return BadRequest("Command received is invalid (json deserialization set null value)");
                }

                _logger.WriteInfo(new LogMessage(string.Concat("Command received ", command.ToString())), LogCategories);
                if (!_validationService.Validate(command, _ruleset.INSERT))
                {
                    _logger.WriteWarning(new LogMessage(string.Concat("Service Bus validation error: ", GetType().ToString())), LogCategories);
                    return BadRequest("Service Bus validation error.");
                }

                ServiceBusMessage message = _mapper.Map(command, new ServiceBusMessage());
                if (string.IsNullOrEmpty(message.ChannelName))
                {
                    throw new DSWException(string.Concat("Queue name to command [", command.ToString(), "] is not mapped"), null, DSWExceptionCode.SC_Mapper);
                }
                ServiceBusMessage response = await _service.SubscribeQueue(message.ChannelName).SendToQueueAsync(message);
                return Ok(response);
            }, BadRequest, Content, InternalServerError, _logger, LogCategories));
        }
Example #2
0
        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();
            }
        }
        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();
            }
            
        }
Example #4
0
        // ========================================
        // method
        // ========================================
        public void Execute(ICommand command)
        {
            if (command == null || !command.CanExecute)
            {
                return;
            }

            try {
                command.Execute();
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("command executed " + command.ToString());
                }

                if (InChain)
                {
                    if (command.CanUndo)
                    {
                        _chainedCommand = _chainedCommand == null ? command : _chainedCommand.Chain(command);
                    }
                }
                else
                {
                    PushToUndo(command);
                }

                OnCommandExecuted(command);
            } catch (Exception e) {
                Logger.Warn("command execution failure: " + command.ToString(), e);
            }
        }
Example #5
0
        public void ProcessSuccessCommand(ICommand command, object response)
        {
            CommandTaskCompletionSource commandTaskCompletionSource;

            if (_commandTaskDict.TryRemove(command.ToString(), out commandTaskCompletionSource))
            {
                var commandResult = new CommandResult {
                    Status = CommandStatus.Success, CommandId = command.ToString(), Result = "执行成功", MessageBody = response
                };
                commandTaskCompletionSource.TaskCompletionSource.TrySetResult(commandResult);
            }
        }
Example #6
0
        public void ProcessFailedSendingCommand(ICommand command)
        {
            CommandTaskCompletionSource commandTaskCompletionSource;

            if (_commandTaskDict.TryRemove(command.ToString(), out commandTaskCompletionSource))
            {
                var commandResult = new CommandResult {
                    Status = CommandStatus.Failed, CommandId = command.ToString(), Result = "请求执行失败."
                };
                commandTaskCompletionSource.TaskCompletionSource.TrySetResult(commandResult);
            }
        }
Example #7
0
        public void Execute(ICommand command)
        {
            if (ServiceLocator.Current.HasServiceProvider())
            {
                throw new InvalidOperationException("A command may not execute within the context of another command.");
            }

            Logger.Debug("Executing command: {0}", command.ToString());

            using (var lifetimeScope = serviceContainer.BeginLifetimeScope())
            {
                var unitOfWork = lifetimeScope.GetInstance <IUnitOfWork>();

                try
                {
                    ServiceLocator.Current.SetCurrentLifetimeScope(lifetimeScope);
                    dispatcher.DispatchToHandlers(command, serviceContainer);
                    unitOfWork.Commit();
                }
                catch (Exception ex)
                {
                    if (unitOfWork != null)
                    {
                        unitOfWork.Rollback();
                    }

                    Logger.Error(ex.GetFullExceptionMessage());
                }
                finally
                {
                    ServiceLocator.Current.SetCurrentLifetimeScope(new DisposedProvider());
                }
            }
        }
        private string BuildCommandString(ICommand[] commands)
        {
            List <List <ICommand> > commandsByType = new List <List <ICommand> >();

            List <ICommand> tmp = new List <ICommand>();

            commandsByType.Add(tmp);
            ICommand prev = null;

            foreach (ICommand c in commands)
            {
                if (prev != null)
                {
                    if (prev.ToString() == c.ToString())
                    {
                        tmp.Add(c);
                    }
                    else
                    {
                        tmp = new List <ICommand> {
                            c
                        };
                        commandsByType.Add(tmp);
                    }
                }
                else
                {
                    tmp.Add(c);
                }

                prev = c;
            }

            StringBuilder sb = new StringBuilder();

            if (commandsByType.Count == 0)
            {
                return("");
            }

            foreach (List <ICommand> commandList in commandsByType)
            {
                if (commandList.Count == 0)
                {
                    continue;
                }

                if (commandList.Count == 1)
                {
                    sb.AppendLine(commandList[0].ToString());
                }
                else
                {
                    sb.AppendLine(commandList[0] + " x" + commandList.Count);
                }
            }


            return(sb.ToString());
        }
Example #9
0
 // ------------------------------
 // private
 // ------------------------------
 private void PushToUndo(ICommand command)
 {
     if (command.CanUndo)
     {
         _redoStack.Clear();
         if (_undoStack.Count > 0)
         {
             var prev  = _undoStack.Peek();
             var compo = prev as CompositeCommand;
             if (compo != null)
             {
                 if (compo.Children.Count > 0)
                 {
                     prev = compo.Children.Last();
                     // todo: CompositeCommandが3階層以上あったときこれでは
                     // 一番最後のleafになるcommandをとれないのを直す
                 }
             }
             if (prev.ShouldMerge(command))
             {
                 var top = _undoStack.Pop();
                 _undoStack.Push(top.Chain(command));
                 if (Logger.IsDebugEnabled)
                 {
                     Logger.Debug("command merged " + command.ToString());
                 }
             }
             else
             {
                 _undoStack.Push(command);
                 if (Logger.IsDebugEnabled)
                 {
                     Logger.Debug("command pushed to undo " + command.ToString());
                 }
             }
         }
         else
         {
             _undoStack.Push(command);
             if (Logger.IsDebugEnabled)
             {
                 Logger.Debug("command pushed to undo " + command.ToString());
             }
         }
     }
 }
 public ICommand ExecuteCommand(ICommand command)
 {
     Stack<ICommand> commandStack = GetCommandStack();
       command.Execute();
       SubscriptionService.SubscriptionService.NotifyAll(command.ToString());
       commandStack.Push(command);
       return command;
 }
Example #11
0
 public void SetCommand(ICommand command)
 {
     if (command.CheckCommand())
     {
         commands.Add(command);
         Console.WriteLine($"玩家:{name},發出 {command.ToString()} 命令");
     }
 }
Example #12
0
        public void ProcessFailedSendingCommand(ICommand command, Exception ex)
        {
            CommandTaskCompletionSource commandTaskCompletionSource;

            if (_commandTaskDict.TryRemove(command.ToString(), out commandTaskCompletionSource))
            {
                commandTaskCompletionSource.TaskCompletionSource.TrySetException(ex);
            }
        }
Example #13
0
 public void RegisterProcessingCommand(ICommand command, TaskCompletionSource <CommandResult> taskCompletionSource)
 {
     if (!_commandTaskDict.TryAdd(command.ToString(), new CommandTaskCompletionSource {
         TaskCompletionSource = taskCompletionSource
     }))
     {
         throw new Exception(string.Format("重复处理请求, type:{0}, id:{1}", command.GetType().Name, command.ToString()));
     }
 }
        public async Task SendCommand(ICommand command)
        {
            if (command == null || !IsConnected || _client == null)
            {
                return;
            }

            await _client.SendMessage(command.ToString());
        }
 public void Execute(string stack, ICommand cmd)
 {
     if (!_stacks.ContainsKey(stack))
     {
         _stacks[stack] = new CommandStack();
     }
     _stacks[stack].Execute(cmd);
     Logger.Performing(cmd.ToString());
 }
Example #16
0
 public void RedoCommand()
 {
     if (commandBuffer.Count <= 0 && commandHistory.Count > 0 && commandHistory.Count > counter)
     {
         ICommand c = commandHistory[counter];
         c.Execute();
         counter++;
         logText.text       = "Log:\tRedo " + c.ToString();
         stepCountText.text = "Step Count: " + counter.ToString();
     }
 }
Example #17
0
 public void UndoCommand()
 {
     if (commandBuffer.Count <= 0 && counter > 0)
     {
         counter--;
         ICommand c = commandHistory[counter];
         c.UndoAction();
         logText.text       = "Log:\tUndo " + c.ToString();
         stepCountText.text = "Step Count: " + counter.ToString();
     }
 }
Example #18
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("\n----------Remote----------\n");
            for (int i = 0; i < length; i++)
            {
                sb.Append($"[slot {i}]\t{commandsOn[i].ToString()} \t{commandsOff[i].ToString()}\n");
            }
            sb.Append($"[undo]\t{undoCommand.ToString()}\n");
            return(sb.ToString());
        }
        /// <summary>
        /// 获取和解析插件集合中的所有对象将其分别装入ICommand,IToll,IToolBar和IMenuDef四个集合中
        /// </summary>
        internal void getPluginArray(PluginContainer pCtner)
        {
            foreach (IPlugin ipi in pCtner)
            {
                ICommand icmd = ipi as ICommand;
                if (icmd != null)
                {
                    this._ICmdContainer.Add(icmd.ToString(), icmd);
                    if (icmd.Category != null && !this._CmdCategory.Contains(icmd.Category))
                    {
                        this._CmdCategory.Add(icmd.Category);
                    }

                    continue;
                }


                ITool itool = ipi as ITool;
                if (itool != null)
                {
                    this._IToolContainer.Add(itool.ToString(), itool);
                    if (itool.Category != null && !this._CmdCategory.Contains(itool.Category))
                    {
                        this._CmdCategory.Add(itool.Category);
                    }
                    continue;
                }


                IToolBarDef itbd = ipi as IToolBarDef;
                if (itbd != null)
                {
                    this._IToolBarDefContainer.Add(itbd.ToString(), itbd);
                    continue;
                }


                IDockableWndDef idwd = ipi as IDockableWndDef;
                if (idwd != null)
                {
                    this._IDockableWndContainer.Add(idwd.ToString(), idwd);
                    continue;
                }

                IMenuDef imd = ipi as IMenuDef;
                if (imd != null)
                {
                    this._IMenuDefContainer.Add(imd.ToString(), imd);
                    continue;
                }
            }
            //throw new System.NotImplementedException();
        }
Example #20
0
    // Update is called once per frame
    void Update()
    {
        if (commandBuffer.Count > 0)
        {
            ICommand command = commandBuffer.Dequeue();
            command.Execute();

            commandHistory.Add(command);
            counter++;
            logText.text       = "Log:\t" + command.ToString();
            stepCountText.text = "Step Count: " + counter.ToString();
        }
    }
Example #21
0
        public override string ToString()
        {
            var s = "";

            s += "\n------ Remote Control -----\n";
            for (int i = 0; i < 7; i++)
            {
                s += string.Format("[slot {0}] {1}  {2}\n",
                                   i, onCommands[i].ToString(), offCommands[i].ToString());
            }
            s += string.Format("[undo] {0}\n",
                               undoCommand.ToString());
            return(s);
        }
Example #22
0
    protected virtual Activity?StartActivity(ICommand originalCommand)
    {
        var operationName = originalCommand.GetType().GetOperationName("Invalidate");
        var activity      = FusionTrace.StartActivity(operationName);

        if (activity != null)
        {
            var tags = new ActivityTagsCollection {
                { "originalCommand", originalCommand.ToString() }
            };
            var activityEvent = new ActivityEvent(operationName, tags: tags);
            activity.AddEvent(activityEvent);
        }
        return(activity);
    }
        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="parameters"></param>
        public virtual void Run(Hashtable parameters)
        {
            string     error   = "";
            ResultCode retCode = ResultCode.Success;

            if (this.CommandList != null)
            {
                for (int i = 0; i < this.CommandList.Count; i++)
                {
                    ICommand command = this.CommandList[i];

                    //// 写日志
                    LogManager.Current.WriteCommonLog(this.JobCode, command.ToString() + " 开始", this.ThreadName);


                    retCode = command.Execute(ref parameters, out error);

                    //// 写日志
                    LogManager.Current.WriteCommonLog(this.JobCode, command.ToString() + " 完成", this.ThreadName);


                    if (retCode == ResultCode.Error)
                    {
                        // 写日志
                        LogManager.Current.WriteErrorLog(JobEntity.Code, command.ToString() + "命令出错:" + error, this.ThreadName);
                        return;
                    }
                    else if (retCode == ResultCode.Break)
                    {
                        // 写日志
                        LogManager.Current.WriteCommonLog(JobEntity.Code, "不需继续处理。", this.ThreadName);
                        continue;
                    }
                }
            }
        }
        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()));
                }
            }
        }
        public override string ToString()
        {
            var oStringBuilder = new StringBuilder();

            oStringBuilder.Append("\n------- Remote Control -------\n");
            int iNoSlots = moOnCommands.Count;

            for (int i = 0; i < iNoSlots; i++)
            {
                oStringBuilder.Append(String.Format("[slot {0}] {1} {2}\n",
                                                    i, moOnCommands[i].ToString(), moOffCommands[i].ToString()));
            }
            oStringBuilder.Append(String.Format("Undo {0}\n", moUndoCommand.ToString()));

            return(oStringBuilder.ToString());
        }
Example #26
0
        protected void executeCommand(ICommand command)
        {
            if (command == null)
            {
                return;
            }
#if UNITY_EDITOR
            string executeCommandText = command.ToString();

            if (executeCommandText != executeCommandOld)
            {
                //UnityEngine.Debug.Log( "<size=12><color=#800080>STRANGE IOC executeCommand: " + executeCommandText + " </color></size>" );
                executeCommandOld = executeCommandText;
            }
#endif
            command.Execute();
        }
Example #27
0
        protected void PrintSpecification()
        {
            Console.WriteLine("Fixture:       {0}", GetType().Name.Replace("_", " "));
            Console.WriteLine("Specification: {0}", GetSpecificationName().Replace("_", " "));

            Console.WriteLine();
            if (_given.Any())
            {
                Console.WriteLine("GIVEN:");

                for (var i = 0; i < _given.Count; i++)
                {
                    PrintAdjusted("  " + (i + 1) + ". ", _given[i].ToString().Trim());
                }
            }
            else
            {
                Console.WriteLine("GIVEN no events");
            }

            if (_when != null)
            {
                Console.WriteLine();
                Console.WriteLine("WHEN:");
                PrintAdjusted("  ", _when.ToString().Trim());
            }

            Console.WriteLine();

            if (_then.Any())
            {
                Console.WriteLine("THEN:");
                for (int i = 0; i < _then.Count; i++)
                {
                    PrintAdjusted("  " + (i + 1) + ". ", _then[i].ToString().Trim());
                }
            }
            else
            {
                Console.WriteLine("THEN nothing.");
            }
        }
Example #28
0
        public static void RegisterCommandHandlers(Assembly x)
        {
            foreach (var t in x.GetExportedTypes())
            {
                if (t.GetInterfaces().Contains(typeof(ICommand)))
                {
                    if (t.IsAbstract)
                    {
                        continue;
                    }
                    try
                    {
                        logger.Info("Loading Command {0} from {1}", t.FullName, x.GetName().Name);
                        ICommand ex = Activator.CreateInstance(t) as ICommand;

                        allCommands[MessageLocalizer.GetDefaultLocalization(ex.CommandName)] = ex;
                        ILogger l = LogManager.GetLogger(t.ToString(), typeof(ExtensionLogger)) as ILogger;
                        ex.Init(l, MessageLocalizer.Instance);
                        if (!Program.Config.Commands.ContainsCommand(MessageLocalizer.GetDefaultLocalization(ex.CommandName)))
                        {
                            Program.Config.Commands.Add(new Config.CommandConfiguration(ex));
                        }
                        else
                        {
                            Program.Config.Commands.UpdateCommand(ex);
                        }
                        foreach (var item in ex.CommandAliases)
                        {
                            if (!String.IsNullOrEmpty(item))
                            {
                                allCommands[item.ToLowerInvariant()] = ex;
                            }
                        }
                        Program.Config.Save(true);
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Error loading {0}: {1}", t.ToString(), ex.ToString());
                    }
                }
            }
        }
Example #29
0
        public void EndChain()
        {
            if (_chainDepth > 0)
            {
                --_chainDepth;

                if (_chainDepth == 0)
                {
                    if (_chainedCommand != null)
                    {
                        PushToUndo(_chainedCommand);
                        OnCommandChainEnded(_chainedCommand);
                        if (Logger.IsDebugEnabled)
                        {
                            Logger.Debug("command chain ended: " + _chainedCommand.ToString());
                        }
                        _chainedCommand = null;
                    }
                }
            }
        }
        private ServiceBusMessage GenerateMessage(Category category, int environmentType, Func <CategoryFascicle, ICommand> func)
        {
            IList <CategoryFascicle> categoryFascicles = category.CategoryFascicles.Where(f => (f.DSWEnvironment == environmentType || f.DSWEnvironment == 0)).ToList();
            CategoryFascicle         categoryFascicle  = categoryFascicles.FirstOrDefault();

            if (categoryFascicles != null && categoryFascicles.Count > 1)
            {
                categoryFascicle = categoryFascicles.FirstOrDefault(f => f.FascicleType == FascicleType.Period);
            }
            IIdentityContext identity = new IdentityContext(_currentIdentity.FullUserName);

            ServiceBusMessage message = null;
            ICommand          command = func(categoryFascicle);

            message = _cqrsMapper.Map(command, new ServiceBusMessage());
            if (string.IsNullOrEmpty(message.ChannelName))
            {
                throw new DSWException(string.Concat("Queue name to command [", command.ToString(), "] is not mapped"), null, DSWExceptionCode.SC_Mapper);
            }
            return(message);
        }
Example #31
0
        private static IDbCommand CreateDbCommand(ICommand command, IDbConnection connection, IDbTransaction transaction = null)
        {
            var dbCommand = connection.CreateCommand();

            dbCommand.CommandType = CommandType.Text;
            dbCommand.CommandText = command.ToString();

            if (transaction != null)
            {
                dbCommand.Transaction = transaction;
            }

            foreach (var parameter in command.Parameters)
            {
                var dbParameter = dbCommand.CreateParameter();
                dbParameter.ParameterName = parameter.Name;
                dbParameter.Value         = parameter.GetValue();
                dbCommand.Parameters.Add(dbParameter);
            }

            return(dbCommand);
        }
        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));
            }
        }
Example #33
0
        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));
            }
        }
Example #34
0
 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());
     }
 }
        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()));
                }
            }
        }
 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);
 }
        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);
              //  };
        }
Example #38
0
        /// <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);
                }
            }
        }
Example #39
0
 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);
 }