void ICommandCenter.Handle(MahuaCommand command)
        {
            var commandHandlers = _commandHandlers.Where(x => x.CanHandle(command));

            foreach (var commandHandler in commandHandlers.Where(x => x.CanHandle(command)))
            {
                commandHandler.Handle(command);
            }
        }
示例#2
0
 public void SendCommand(MahuaCommand command)
 {
     WriteDiagnostics(() => command);
     using (var beginLifetimeScope = _container.BeginLifetimeScope())
     {
         SetContainer(beginLifetimeScope);
         var center = beginLifetimeScope.Resolve <ICommandCenter>();
         center.Handle(command);
     }
 }
        public static TResult SendCommand <TResult>(this IPluginLoader pluginLoader, MahuaCommand command)
            where TResult : MahuaCommandResult, new()
        {
            MahuaCommandResult result;

            pluginLoader.SendCommandWithResult(command, out result);
            //todo 跨AppDomain时遇到了强制转换失败的问题,因此采用了json序列化的办法
            var re = ConvertType <TResult>(result);

            return(re);
        }
示例#4
0
        public void SendCommandWithResult(MahuaCommand command, out MahuaCommandResult mahuaCommandResult)
        {
            WriteDiagnostics(() => command);

            using (var beginLifetimeScope = _container.BeginLifetimeScope())
            {
                SetContainer(beginLifetimeScope);
                var center = beginLifetimeScope.Resolve <ICommandCenter>();
                center.Handle(command, out mahuaCommandResult);
                var re = mahuaCommandResult;
                WriteDiagnostics(() => re);
            }
        }
        void ICommandCenter.Handle(MahuaCommand command, out MahuaCommandResult mahuaCommandResult)
        {
            var commandHandlers = _resultCommandHandlers.FirstOrDefault(x => x.CanHandle(command));

            mahuaCommandResult = (MahuaCommandResult)commandHandlers?.Handle(command);
        }
 public static void SendCommand(this IPluginLoader pluginLoader, MahuaCommand command)
 {
     pluginLoader.Handle(GlobalCache.JavaScriptSerializer.Serialize(command),
                         command.GetType().FullName);
 }
示例#7
0
 public bool CanHandle(MahuaCommand command)
 {
     return(command is TCommand);
 }