private void Cleanup()
 {
     currentData      = null;
     currentBehaviour = new HotbarActionBehaviour();;
     currentDirection = Vector3.zero;
     builder          = null;
 }
        public void executeCommandBase(NodeClick click, CommandType type, UpdateType update, bool rebar, bool update_measure_heads)
        {
            click.populateCommandSelections(selections);
            IActionBuilder builder = ExecutorFactory.getBuilderFromType(type, selections);

            bool result = executor.executeCommand(builder);

            if (result)
            {
                Updater.populateMouseClick(click);
                if (update_measure_heads)
                {
                    click.PartNode.beginRedrawMeasureHeads();
                }
                runUpdate(click, update);
                if (rebar)
                {
                    Updater.rebarMeasures(click.MeasureNodes);
                }
                if (update_measure_heads)
                {
                    click.PartNode.endRedrawMeasureheads();
                }
            }

            click.setHandled();
            selections.Clear();
        }
Example #3
0
        public ThingContextFactoryTest()
        {
            _response = Substitute.For <IThingResponseBuilder>();
            _event    = Substitute.For <IEventBuilder>();
            _property = Substitute.For <IPropertyBuilder>();
            _action   = Substitute.For <IActionBuilder>();

            _factory = new ThingContextFactory(_event, _property, _response, _action);

            _event
            .Build()
            .Returns(new Dictionary <string, EventCollection>());

            _response
            .Build()
            .Returns(new Dictionary <string, object>());

            _action
            .Build()
            .Returns(new Dictionary <string, ActionCollection>());

            _property
            .Build()
            .Returns(new Dictionary <string, IThingProperty>());
        }
        public static IActionBuilder ConductDefaultContent(this IActionBuilder builder, Conductor <IStockTickerContentViewModel> conductor)
        {
            var future = new Future <StockDetailModel>();

            future.SetValue(null);

            return(builder.ConductContent(future, conductor));
        }
Example #5
0
 /// <summary>
 /// Initialize a new instance of <see cref="IEventBuilder"/>.
 /// </summary>
 /// <param name="event"></param>
 /// <param name="property"></param>
 /// <param name="response"></param>
 /// <param name="action"></param>
 public ThingContextFactory(IEventBuilder @event, IPropertyBuilder property,
                            IThingResponseBuilder response, IActionBuilder action)
 {
     _event    = @event;
     _property = property;
     _response = response;
     _action   = action;
 }
Example #6
0
        public static IActionBuilder BuilderByAction(ActionModel action)
        {
            IActionBuilder builder = null;

            switch (action.Action)
            {
            case Core.Action.Types.ActionType.WriteFile:
                builder = new WriteFileActionBuilder();
                break;

            case Core.Action.Types.ActionType.IF:
                builder = new IFActionActionBuilder();
                break;

            case Core.Action.Types.ActionType.HttpRequest:
                builder = new HttpRequestActionBuilder();
                break;

            case Core.Action.Types.ActionType.StartProcess:
                builder = new StartProcessActionBuilder();
                break;

            case Core.Action.Types.ActionType.Shutdown:
                builder = new ShutdownActionBuilder();
                break;

            case Core.Action.Types.ActionType.OpenURL:
                builder = new OpenURLActionBuilder();
                break;

            case Core.Action.Types.ActionType.Snipping:
                builder = new SnippingActionBuilder();
                break;

            case Core.Action.Types.ActionType.DeleteFile:
                builder = new DeleteFileActionBuilder();
                break;

            case Core.Action.Types.ActionType.SoundPlay:
                builder = new SoundPlayActionBuilder();
                break;

            case Core.Action.Types.ActionType.GetIPAddress:
                builder = new GetIPAddressActionBuilder();
                break;

            case Core.Action.Types.ActionType.Keyboard:
                builder = new KeyboardActionBuilder();
                break;
            }
            if (builder != null)
            {
                builder.ImportAction(action);
            }
            return(builder);
        }
Example #7
0
 public StunEffectBuilderStub()
     : base("Stun", (c, _) => c)
 {
     _actionBuilder =
         new ActionBuilderStub(
             EntityBuilderStub.Self(),
             new EnemyBuilderStub(),
             "Stun",
             (c, _) => c);
 }
        public bool executeCommand(IActionBuilder builder)
        {
            var validator = builder.buildValidator();

            if (validator.validateAction())
            {
                var command = builder.buildCommand();
                command?.executeAction();
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Chain the given action returning <see cref="Unit"/>
        /// </summary>
        /// <typeparam name="TAction">The type of the next action</typeparam>
        /// <param name="source">The builder source</param>
        /// <param name="nextAction">The action to chain</param>
        /// <returns>A new builder</returns>
        public static IActionBuilder <TAction, Unit> Then <TAction>(this IActionBuilder source, TAction nextAction) where TAction : class, IAction <Unit>
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (nextAction == null)
            {
                throw new ArgumentNullException(nameof(nextAction));
            }

            return(source.Then <TAction, Unit>(nextAction));
        }
Example #10
0
        public void AddItem(ActionItemModel action, IActionBuilder builder = null)
        {
            if (!appendActionItemTempList.Contains(action))
            {
                appendActionItemTempList.Add(action);
                appendBuilderTempList.Add(builder);
            }

            if (isRendering)
            {
                return;
            }
            AddItemControl(action, builder);
        }
        public void StartAction(Entity parent, BindableActions selectedAction)
        {
            //skills should only be cast from here
            if (!CharacterActions[selectedAction].CanCast(parent.unitData.ValueContainer))
            {
                return;
            }
            builder     = CharacterActions[selectedAction].builder;
            currentData = builder.ReturnActionData();

            currentBehaviour = builder.ReturnHotbarBehaviour(parent.unitData.ValueContainer);

            currentDirection = new Vector3(parent.facingDirection.x, parent.facingDirection.y, 0); //set direction
        }
        public void Then_WithInferenceParameter_ShouldReturnCorrectValue(
            Mock <IActionBuilder> source,
            IAction <string> action,
            IActionBuilder <IAction <string>, string> expected
            )
        {
            //arrange
            source.Setup(s => s.Then <IAction <string>, string>(action)).Returns(expected);
            //act
            var actual = ActionBuilderExtensions.Then(source.Object, action, default(string));

            //assert
            actual.Should().Be(expected);
        }
        public void Then_WithActionUnit_ShouldReturnCorrectValue(
            Mock <IActionBuilder> source,
            IAction <Unit> action,
            IActionBuilder <IAction <Unit>, Unit> expected
            )
        {
            //arrange
            source.Setup(s => s.Then <IAction <Unit>, Unit>(action)).Returns(expected);
            //act
            var actual = ActionBuilderExtensions.Then(source.Object, action);

            //assert
            actual.Should().Be(expected);
        }
        /// <summary>
        /// Chain the given action
        /// </summary>
        /// <typeparam name="TAction">The type of the next action</typeparam>
        /// <typeparam name="TResult">The type fo the next action result</typeparam>
        /// <param name="source">The builder source</param>
        /// <param name="nextAction">The action to chain</param>
        /// <param name="dummy">An value used for infering the result type. This parameter is never used.</param>
        /// <returns>A new builder</returns>
        public static IActionBuilder <TAction, TResult> Then <TAction, TResult>(
            this IActionBuilder source,
            TAction nextAction,
#pragma warning disable RCS1163 // Used to inference
            TResult dummy)
#pragma warning restore RCS1163 // Unused parameter.
            where TAction : class, IAction <TResult>
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (nextAction == null)
            {
                throw new ArgumentNullException(nameof(nextAction));
            }

            return(source.Then <TAction, TResult>(nextAction));
        }
Example #15
0
        public override IAction CreateAction(string builderID, string keyID, BaseViewModel viewModel = null, ILogger logger = null)
        {
            //try to get the registered builder
            IActionBuilder builder = null;

            try
            {
                builder = _builders[builderID];
            }
            catch
            {
                return(null);
            }

            // Build the action
            if (!builder.Locker.IsLock)
            {
                return(builder.BuildMainAction(keyID));
            }
            else
            {
                return(builder.BuildAlternativeActionWhenFactoryIsLock(keyID));
            }
        }
 public static object Then(IActionBuilder source, IAction <int> nextAction) => ActionBuilderExtensions.Then(source, nextAction, 0);
Example #17
0
 public static IActionBuilder Notify(this IActionBuilder builder, object message)
 {
     return(builder.Execute <INotify>(new { message }));
 }
Example #18
0
        public static IActionBuilder WithBusyIndication(this IActionBuilder builder, Action <IActionBuilder> configure, string message)
        {
            Guid requestId = Guid.NewGuid();

            return(builder.ScopeWith <IShowBusyIndication, IHideBusyIndication>(configure, new { requestId, message }, new { requestId }));
        }
Example #19
0
 public static void Method(this IActionBuilder self, string value)
 {
     self.Method(value);
 }
 public static IActionBuilder ExecuteITestResult(this IActionBuilder builder, string input)
 {
     return(builder.Execute <ITestResult>(new { input }));
 }
 public static IActionBuilder ScopeWithITestResult(this IActionBuilder builder, Action <IActionBuilder> scope, string enter, string exit)
 {
     return(builder.ScopeWith <ITestResult, ITestResult>(scope, new { input = enter }, new { input = exit }));
 }
 public DefaultMvcRequestTaskRunner(IActionBuilder actionBuilder, IModelBinder modelBinder)
 {
     _actionBuilder = actionBuilder;
     _modelBinder   = modelBinder;
 }
 public static IActionBuilder ExecuteITestResult(this IActionBuilder builder)
 {
     return(builder.Execute <ITestResult>());
 }
 public static IActionBuilder ConductContent(this IActionBuilder builder, IFutureValue <StockDetailModel> detailModel, Conductor <IStockTickerContentViewModel> conductor)
 {
     return(builder.Execute <IConductStockTickerContent>(new { detailModel, conductor = (Action <IStockTickerContentViewModel>)conductor.ActivateItem }));
 }
        public static IActionBuilder BuilderByActionItem(ActionItemModel action)
        {
            IActionBuilder builder = null;

            switch (action.ActionType)
            {
            case ActionType.WriteFile:
                builder = new WriteFileActionBuilder();
                break;

            case ActionType.IF:
                builder = new IFActionActionBuilder();
                break;

            case ActionType.HttpRequest:
                builder = new HttpRequestActionBuilder();
                break;

            case ActionType.StartProcess:
                builder = new StartProcessActionBuilder();
                break;

            case ActionType.Shutdown:
                builder = new ShutdownActionBuilder();
                break;

            case ActionType.OpenURL:
                builder = new OpenURLActionBuilder();
                break;

            case ActionType.Snipping:
                builder = new SnippingActionBuilder();
                break;

            case ActionType.DeleteFile:
                builder = new DeleteFileActionBuilder();
                break;

            case ActionType.SoundPlay:
                builder = new SoundPlayActionBuilder();
                break;

            case ActionType.GetIPAddress:
                builder = new GetIPAddressActionBuilder();
                break;

            case ActionType.Keyboard:
                builder = new KeyboardActionBuilder();
                break;

            case ActionType.SystemNotification:
                builder = new SystemNotificationActionBuilder();
                break;

            case ActionType.DownloadFile:
                builder = new DownloadFileActionBuilder();
                break;

            case ActionType.Dialog:
                builder = new DialogActionBuilder();
                break;

            case ActionType.Delay:
                builder = new DelayActionBuilder();
                break;

            case ActionType.Loops:
                builder = new LoopsActionBuilder();
                break;

            case ActionType.KillProcess:
                builder = new KillProcessActionBuilder();
                break;

            case ActionType.SetDeviceVolume:
                builder = new SetDeviceVolumeActionBuilder();
                break;

            case ActionType.Regex:
                builder = new RegexActionBuilder();
                break;

            case ActionType.ReadFile:
                builder = new ReadFileActionBuilder();
                break;

            case ActionType.JsonDeserialize:
                builder = new JsonDeserializeActionBuilder();
                break;
            }
            if (builder != null)
            {
                builder.ImportActionItem(action);
            }
            return(builder);
        }
Example #26
0
 public static IActionBuilder SuggestUsernames(this IActionBuilder builder, PotentialNewUserModel potentialNewUser, ICollection <string> suggestedUsernames)
 {
     return(builder.Execute <ISuggestUsernames>(new { potentialNewUser, suggestedUsernames }));
 }
 public static IActionBuilder Search(this IActionBuilder builder, string searchPattern, ICollection <StockSearchModel> foundStocks)
 {
     return(builder.Execute <ISearchStocks>(new { searchPattern, foundStocks }));
 }
 public static IActionBuilder GetDetails(this IActionBuilder builder, StockSearchModel searchModel, IFutureValueSetter <StockDetailModel> detailModel)
 {
     return(builder.Execute <IGetStockDetails>(new { symbol = searchModel.ToSymbol(), detailModel }));
 }
Example #29
0
        private void AddItemControl(ActionItemModel action, IActionBuilder builder = null)
        {
            isRendering = true;
            double Y = 0;

            if (ActionItems.Count > 0)
            {
                var lastItem    = ActionItems.Last();
                var lastItemTTF = lastItem.RenderTransform as TranslateTransform;
                Y = lastItemTTF.Y + lastItem.ActualHeight;
            }

            var item = new ActionItem();

            item.ActionContainer = this;
            item.DataContext     = this;
            item.VMDataContext   = this.DataContext;
            BindingOperations.SetBinding(item, ActionItem.ContainerStateProperty, new Binding()
            {
                Source = this,
                Path   = new PropertyPath(nameof(State)),
                Mode   = BindingMode.Default,
            });
            BindingOperations.SetBinding(item, ActionItem.RuningIDProperty, new Binding()
            {
                Source = DataContext,
                Path   = new PropertyPath("RuningActionID"),
                Mode   = BindingMode.Default,
            });
            BindingOperations.SetBinding(item, ActionItem.RuningStateProperty, new Binding()
            {
                Source = DataContext,
                Path   = new PropertyPath("RuningActionState"),
                Mode   = BindingMode.Default,
            });
            item.ID = action.ID;
            //item.InputDataModel = inputdata == null ? ActionData.GetCreateDefaultInputData(action.ActionType) : inputdata;
            item.Builder = builder == null?ActionBuilder.BuilderByActionItem(action) : builder;

            item.Action            = action;
            item.VerticalAlignment = VerticalAlignment.Top;
            var ttf = item.RenderTransform as TranslateTransform;

            ttf.Y  = Y;
            item.Y = Y;
            item.MouseLeftButtonDown += Item_MouseLeftButtonDown;
            item.MouseLeftButtonUp   += Item_MouseLeftButtonUp;
            item.MouseMove           += Item_MouseMove;
            ttf.Changed += (e, c) =>
            {
                item.Y = ttf.Y;
            };

            item.OnRenderDone += (e, c) =>
            {
                if (item.Tag != null)
                {
                    //如果tag不为null表示已加载完成了
                    return;
                }
                item.Tag = string.Empty;
                if (ActionItems.Count == 1)
                {
                    //仅存在一个时使用auto height
                    ActionPanel.Height = Double.NaN;
                }
                else
                {
                    ActionPanel.Height = ActionPanel.ActualHeight + item.ActualHeight;
                }
                //ActionPanel.Height += item.ActualHeight;
                //if (double.IsNaN(ActionPanel.Height))
                //{
                //    ActionPanel.Height = item.ActualHeight;
                //}
                UpdateActionHeight(item);
                ActionTempPanel.Children.Remove(item);
                ActionPanel.Children.Add(item);
                //继续队列
                appendActionItemTempList.RemoveAt(0);
                appendBuilderTempList.RemoveAt(0);

                isRendering = false;
                if (appendActionItemTempList.Count > 0)
                {
                    AddItem(appendActionItemTempList[0], appendBuilderTempList[0]);
                }
                else
                {
                    ResetAllActionsMarigin();
                }
                //继续监控item高度变化
                item.LayoutUpdated += (e, v) =>
                {
                    UpdateActionHeight(item);
                };
            };
            //ActionPanel.Children.Add(item);
            //添加到临时容器中
            ActionTempPanel.Children.Add(item);
            ActionItems.Add(item);
            SortAction();
        }
Example #30
0
 public static IActionBuilder WithLogin(this IActionBuilder builder, Action <IActionBuilder> configure)
 {
     return(builder.ScopeWith <IAuthenticate, IMissing>(configure));
 }