예제 #1
0
파일: Loader.cs 프로젝트: TheSynt4x/AutoQW
        public void Load()
        {
            _plugin = new ChatPlugin();

            var chat = new Chatm();

            chat.OnMessage += _chatForm.OnMessage;

            _packets.Add(chat);
            _packets.Add(new Uotls());

            BotTerminal.Instance.RegisterCommand(_plugin);

            foreach (var packet in _packets)
            {
                Player.Client.RegisterHandler(packet);
            }

            _chatForm = new Chat();

            Thread mThread = new Thread(delegate()
            {
                _chatForm.ShowDialog();
            });

            mThread.SetApartmentState(ApartmentState.STA);

            mThread.Start();
        }
        public void Add(string commandType, ICommandHandle commandHandle)
        {
            _commandHandleDic.TryAdd(commandType, commandHandle);

            //if (_commandHandleDic.ContainsKey(commandType))
            //    _commandHandleDic.Add(commandType,commandHandle);
        }
예제 #3
0
파일: CommonDB.cs 프로젝트: heianxing/sod
 /// <summary>
 /// 注册一个命令处理器
 /// </summary>
 /// <param name="handle">命令处理器实例对象</param>
 public void RegisterCommandHandle(ICommandHandle handle)
 {
     if (handle != null)
     {
         //if (this.commandHandles == null)
         //    this.commandHandles = new List<ICommandHandle>();
         this.commandHandles.Add(handle);
     }
 }
예제 #4
0
 public static Task WithCommandHandlerAsync <TCommand>(this IBusClient bus,
                                                       ICommandHandle <TCommand> handler) where TCommand : ICommand
 => bus.SubscribeAsync <TCommand>(
     msg => handler.HandleAsync(msg),
     ctx => ctx.UseSubscribeConfiguration(
         cfg => cfg.FromDeclaredQueue(
             q => q.WithName(GetQueueName <TCommand>())
             )
         )
     );
예제 #5
0
        public void Subscribe <TCommand>(ICommandHandle <TCommand> commandHandle) where TCommand : ICommand
        {
            var type = typeof(TCommand);

            if (!commandHandles.ContainsKey(type))
            {
                var hash = new HashSet <dynamic>();
                hash.Add(commandHandle);
                commandHandles.Add(type, hash);
            }
            else
            {
                var hash = commandHandles[type];
                if (!hash.Contains(commandHandle))
                {
                    hash.Add(commandHandle);
                }
            }
        }
예제 #6
0
 public void UnregisterCommand(ICommandHandle command) => commands.Remove(command);
예제 #7
0
 public void RegisterCommand(ICommandHandle command) => RegisterCommand(command, commands);
예제 #8
0
 internal void RegisterHandle(ICommandHandle handle)
 {
     _handles.Add(handle);
 }