예제 #1
0
        public async Task <AvrCommandExecutionStatus> ExecuteAsync()
        {
            UriBuilder bob = new UriBuilder();

            bob.Host = mAvrDevice.DeviceDescribtor.Address.Host;
            bob.Path = sCommandPath;
            AvrHttpPostClient httpClient = new AvrHttpPostClient();

            httpClient.Uri       = bob.Uri;
            httpClient.XmlString = XmlString;
            AvrHttpResponse response = await httpClient.SendHttpRequest();

            StringReader reader = new StringReader(response.ResponseString);
            XmlDocument  doc    = new XmlDocument();

            try
            {
                doc.Load(reader);
            }
            catch (Exception e)
            {
                return(new AvrCommandExecutionStatus(response.Status, AvrCommandExecutionStatusCode.BAD_RESPONSE));
            }

            return(new AvrCommandExecutionStatus(response.Status, CommandStrategy.ProcessXmlResponse(mAvrDevice, doc)));
        }
예제 #2
0
 /// <summary> Queue the command wrapped in a command strategy. </summary>
 /// <param name="commandStrategy"> The command strategy. </param>
 public override void QueueCommand(CommandStrategy commandStrategy)
 {
     lock (Queue)
     {
         // Process all generic enqueue strategies
         Queue.Enqueue(commandStrategy);
         foreach (var generalStrategy in GeneralStrategies) { generalStrategy.OnEnqueue(); }
     }
 }
예제 #3
0
    public void UseItem_menu(ItemData item, PlayerChar target)
    {
        var strtegy = CommandStrategy.GetStrategy(item);
        var friends = _playerDisplayers.Select(x => (BattleChar)x._mycharData).ToList();
        var user    = new PlayerChar(SaveDataController.Instance.GetDB_var <PlayerDB, SavedDBData_player>()[0]);

        strtegy.TurnAction(user, target, item, friends: friends);
        target.SyncData_This2Data();
        SaveDataController.Instance.SetData <PlayerDB, SavedDBData_player>(target._PlayerData);
    }
 /// <summary> Queue the command wrapped in a command strategy. </summary>
 /// <param name="commandStrategy"> The command strategy. </param>
 public override void QueueCommand(CommandStrategy commandStrategy)
 {
     lock (Queue)
     {
         // Process all generic enqueue strategies
         Queue.Enqueue(commandStrategy);
         foreach (var generalStrategy in GeneralStrategies) { generalStrategy.OnEnqueue(); }
     }
     if (NewLineReceived != null) NewLineReceived(this, new NewLineEvent.NewLineArgs(commandStrategy.Command));
 }
예제 #5
0
        public void StaticHandlerThrows()
        {
            CommandStrategy    strategy = new CommandStrategy();
            MockBuilderContext context  = new MockBuilderContext(strategy);
            WorkItem           wi       = new TestableRootWorkItem();

            context.Locator.Add(new DependencyResolutionLocatorKey(typeof(WorkItem), null), wi);

            SampleStaticClass sample = new SampleStaticClass();

            strategy.BuildUp(context, typeof(SampleStaticClass), sample, null);
        }
예제 #6
0
 /// <summary> Queue the command wrapped in a command strategy. </summary>
 /// <param name="commandStrategy"> The command strategy. </param>
 public override void QueueCommand(CommandStrategy commandStrategy)
 {
     lock (Queue)
     {
         // Process all generic enqueue strategies
         Queue.Enqueue(commandStrategy);
         foreach (var generalStrategy in GeneralStrategies)
         {
             generalStrategy.OnEnqueue();
         }
     }
 }
예제 #7
0
        public CommandStrategyTests()
        {
            commandExecutor = new List <ICommandExecutor>();
            commandExecutor.Add(new LeftCommandExecutor());
            commandExecutor.Add(new MoveCommandExecutor(new ToyTable(5, 5)));
            var parameterConvertor = new ParameterConvertor();

            commandExecutor.Add(new PlaceCommandExecutor(parameterConvertor, new ToyTable(5, 5)));
            commandExecutor.Add(new RightCommandExecutor());

            sut = new CommandStrategy(commandExecutor);
        }
예제 #8
0
        public void AddingObjectWithCommandHandlerRegisterTheCommand()
        {
            CommandStrategy    strategy = new CommandStrategy();
            MockBuilderContext context  = new MockBuilderContext(strategy);
            WorkItem           wi       = new TestableRootWorkItem();

            context.Locator.Add(new DependencyResolutionLocatorKey(typeof(WorkItem), null), wi);

            SampleClass sample = new SampleClass();

            strategy.BuildUp(context, typeof(SampleClass), sample, null);

            Assert.IsTrue(wi.Items.Contains("TestCommand"));
        }
예제 #9
0
 public SchedulerService(CommandStrategy strategy)
 {
     ServiceName = Methods.ConfigAsString("ServiceName", "Jetproger.Tools.Service");
     //var strategy = CoreMethods.Async
     //    .Prepare<TreeLoadCallerLocal>()
     //    .Set(x => x.Code, treeCode)
     //    .Result<ITreeLoadCommand>()
     //    .Tree
     //    .AsCommandStrategy();
     _strategies = strategy.Items.Select(x => new Tuple <Command, CommandStrategy>(x.Command, new CommandStrategy {
         Items = new List <CommandAgent> {
             x
         }
     })).ToArray();
 }
예제 #10
0
        /// <summary> Queue the send command wrapped in a command strategy. </summary>
        /// <param name="commandStrategy"> The command strategy. </param>
        public override void QueueCommand(CommandStrategy commandStrategy)
        {
            lock (Queue)
            {
                // Process commandStrategy enqueue associated with command
                commandStrategy.CommandQueue = Queue;
                commandStrategy.ThreadRunState = ThreadRunState;

                commandStrategy.Enqueue();

                // Process all generic enqueue strategies
                foreach (var generalStrategy in GeneralStrategies) { generalStrategy.OnEnqueue(); }

            }
        }
예제 #11
0
        public RobotControlProcesserTests()
        {
            var commandExecutor = new List <ICommandExecutor>
            {
                new LeftCommandExecutor(),
                new MoveCommandExecutor(new ToyTable(5, 5))
            };
            var parameterConvertor = new ParameterConvertor();

            commandExecutor.Add(new PlaceCommandExecutor(parameterConvertor, new ToyTable(5, 5)));
            commandExecutor.Add(new RightCommandExecutor());

            var CommandStrategy = new CommandStrategy(commandExecutor);

            sut = new RobotControlProcesser(parameterConvertor, CommandStrategy);
        }
예제 #12
0
 /// <summary> Queue the command wrapped in a command strategy. </summary>
 /// <param name="commandStrategy"> The command strategy. </param>
 public override void QueueCommand(CommandStrategy commandStrategy)
 {
     lock (Queue)
     {
         // Process all generic enqueue strategies
         Queue.Enqueue(commandStrategy);
         foreach (var generalStrategy in GeneralStrategies)
         {
             generalStrategy.OnEnqueue();
         }
     }
     if (NewLineReceived != null)
     {
         NewLineReceived(this, new NewLineEvent.NewLineArgs(commandStrategy.Command));
     }
 }
예제 #13
0
        /// <summary> Queue the send command wrapped in a command strategy. </summary>
        /// <param name="commandStrategy"> The command strategy. </param>
        public override void QueueCommand(CommandStrategy commandStrategy)
        {
            lock (Queue)
            {
                // Process commandStrategy enqueue associated with command
                commandStrategy.CommandQueue   = Queue;
                commandStrategy.ThreadRunState = ThreadRunState;

                commandStrategy.Enqueue();

                // Process all generic enqueue strategies
                foreach (var generalStrategy in GeneralStrategies)
                {
                    generalStrategy.OnEnqueue();
                }
            }
        }
 /// <summary> Queue the command wrapped in a command strategy. </summary>
 /// <param name="commandStrategy"> The command strategy. </param>
 public override void QueueCommand(CommandStrategy commandStrategy)
 {
     lock (Queue)
     {
         // Process all generic enqueue strategies
         Queue.Enqueue(commandStrategy);
         foreach (var generalStrategy in GeneralStrategies)
         {
             generalStrategy.OnEnqueue();
         }
     }
     // Give a signal to indicate that a new item has been queued
     EventWaiter.Set();
     if (NewLineReceived != null)
     {
         NewLineReceived(this, new NewLineEvent.NewLineArgs(commandStrategy.Command));
     }
 }
 public abstract TryAsync <TContext> Handle(
     TContext context,
     CommandStrategy <TContext> strategy
     );
 public override TryAsync <StoreFrontContext> Handle(StoreFrontContext context, CommandStrategy <StoreFrontContext> strategy)
 {
     throw new NotImplementedException();
 }
예제 #17
0
 /// <summary> Put  a command wrapped in a strategy at the back of the sent queue.</summary>
 /// <param name="commandStrategy"> The command strategy. </param>
 public void QueueCommand(CommandStrategy commandStrategy)
 {
     _sendCommandQueue.QueueCommand(commandStrategy);
 }
 public override TryAsync <AccountLedgerContext> Handle(AccountLedgerContext context,
                                                        CommandStrategy <AccountLedgerContext> strategy)
 => ApplyStrategy(context with {
예제 #19
0
 public override TryAsync <UserCommandContext> Handle(
     UserCommandContext context,
     CommandStrategy <UserCommandContext> strategy
     ) =>
 ApplyStrategy(context with {
 protected TryAsync <TContext> ApplyStrategy(TContext context, CommandStrategy <TContext> s) => s(context);