public static Polyface IsStrategizedTouchable(this Polyface root, ILogicOf<Polyface> logic)
 {
     Condition.Requires(root).IsNotNull();
     logic.Context = root;
     var composited = new StrategizedTouchable(logic);
     root.IsHasTouchable(composited);
     return root;
 }
Example #2
0
 private StrategizedTaskOf(string id, IValueOf <T> context, ILogicOf <T> performLogic, ILogicOf <T> cancelLogic = null)
     : base(id)
 {
     Condition.Requires(performLogic).IsNotNull();
     this.PerformLogic = performLogic;
     this.CancelLogic  = cancelLogic;
     this.Context      = context;
 }
        public static Polyface IsStrategizedTouchable(this Polyface root, ILogicOf <Polyface> logic)
        {
            Condition.Requires(root).IsNotNull();
            logic.Context = root;
            var composited = new StrategizedTouchable(logic);

            root.IsHasTouchable(composited);
            return(root);
        }
Example #4
0
        public IPollingDecoration SetBackgroundAction(ILogicOf <ITask> backgroundAction, double backgroundIntervalMSecs = 30000)
        {
            this.ClearBackgroundAction();
            backgroundAction.Context = (this as ITask);

            this.Background = new BackgroundHost(true, backgroundIntervalMSecs, backgroundAction);

            return(this);
        }
Example #5
0
        public IPollingDecoration SetBackgroundAction(ILogicOf<ITask> backgroundAction, double backgroundIntervalMSecs = 30000)
        {
            this.ClearBackgroundAction();
            backgroundAction.Context = (this as ITask);

            this.Background = new BackgroundHost(true, backgroundIntervalMSecs, backgroundAction);

            return this;
        }
Example #6
0
 public StrategizedServiceOf(T context, ILogicOf <T> initStrategy,
                             ILogicOf <T> startStrategy,
                             ILogicOf <T> stopStrategy)
     : base()
 {
     this.Context       = context;
     this.InitStrategy  = initStrategy;
     this.StartStrategy = startStrategy;
     this.StopStrategy  = stopStrategy;
 }
Example #7
0
        /// <summary>
        /// invokes the arg decorations, then the logic decorations, then invokes the logic
        /// </summary>
        private TResult InvokeDecoratedArgAndLogic()
        {
            this.Logger.Do((x) => x.LogVerbose("InvokeDecoratedArgAndLogic started", null));

            this.Logger.Do((x) => x.LogVerbose("Arg", this.Arg));
            this.ProcessedArg = this.DecoratedArg.GetValue(); //invoke arg decoration chain (adjusters and observers)
            this.Logger.Do((x) => x.LogVerbose("ProcessedArg", this.ProcessedArg));

            ILogicOf <TArg> logicOf      = (ILogicOf <TArg>) this.DecoratedLogic;
            var             logicResults = logicOf.Perform(this.ProcessedArg) as LogicOfTo <TArg, TResult>;

            this.Logger.Do((x) => x.LogVerbose("Logic performed", null));
            this.Result = logicResults.Result;
            this.Logger.Do((x) => x.LogVerbose("Result", this.Result));

            //decorate the result
            this.Logger.Do((x) => x.LogVerbose("Decorate result started", null));
            var intercepts = this.Layers;

            if (this.Result != null)
            {
                IValueOf <TResult> resultOf = this.Result.AsNaturalValue();

                //decorate the adjustments
                intercepts.WithEach((intercept) =>
                {
                    if (intercept.ResultDecorator != null)
                    {
                        resultOf = resultOf.Adjust(intercept.ResultDecorator);
                    }
                });
                //decorate the observations
                intercepts.WithEach((intercept) =>
                {
                    if (intercept.ResultValidator != null)
                    {
                        resultOf = resultOf.Observe(null, LogicOf <IValueOf <TResult> > .New((x) =>
                        {
                            intercept.ResultValidator.Perform(resultOf);
                        }));
                    }
                });
                this.Logger.Do((x) => x.LogVerbose("Decorate result completed", null));

                this.DecoratedResult = resultOf;
                this.ProcessedResult = resultOf.GetValue(); //invoke the decorations

                this.Logger.Do((x) => x.LogVerbose("ProcessedResult", this.ProcessedResult));
            }

            return(this.ProcessedResult);
        }
Example #8
0
 public static StrategizedServiceOf <T> New(T context, ILogicOf <T> initStrategy,
                                            ILogicOf <T> startStrategy,
                                            ILogicOf <T> stopStrategy)
 {
     return(new StrategizedServiceOf <T>(context, initStrategy, startStrategy, stopStrategy));
 }
Example #9
0
 /// <summary>
 /// fluently sets the cancel logic
 /// </summary>
 /// <param name="logic"></param>
 /// <returns></returns>
 public StrategizedTaskOf <T> Cancels(ILogicOf <T> logic)
 {
     Condition.Requires(logic).IsNotNull();
     this.PerformLogic = logic;
     return(this);
 }
Example #10
0
        public static StrategizedTaskOf <Targ> New <Targ>(string id, IValueOf <Targ> context, ILogicOf <Targ> performLogic, ILogicOf <Targ> cancelLogic = null)
        {
            var rv = new StrategizedTaskOf <Targ>(id, context, performLogic, cancelLogic);

            ////now some fancy stuff...
            ////if the context is IConditionalValueOf<T>, it means there's a condition that prevents the getting of the context value
            ////apply a conditional constraint to the task's Perform indicating this condition must be true
            //if (context is IConditionalValueOf<Targ>)
            //{
            //    IConditionalValueOf<Targ> cContext = context as IConditionalValueOf<Targ>;
            //    var rTask = rv.ANDPerformCondition(cContext.CheckCondition);
            //    return rTask;
            //}

            return(rv);
        }
Example #11
0
 public PollingDecoration(ITask decorated, ILogicOf <ITask> backgroundAction, double backgroundIntervalMSecs = 30000)
     : base(decorated)
 {
     this.SetBackgroundAction(backgroundAction, backgroundIntervalMSecs);
 }
Example #12
0
 public PollingDecoration(ITask decorated, ILogicOf<ITask> backgroundAction, double backgroundIntervalMSecs = 30000)
     : base(decorated)
 {
     this.SetBackgroundAction(backgroundAction, backgroundIntervalMSecs);
 }