Example #1
0
        public ActivityDescriptor <TActivity> Fork <TActivity>() where TActivity : class, IActivity
        {
            var activityDescriptor = new ActivityDescriptor <TActivity>();

            myForks.Add(activityDescriptor);
            return(activityDescriptor);
        }
        internal ActivityBinder(
            [NotNull] ActivityDescriptor <TActivity> activityDescriptor,
            [NotNull] Expression <Func <TActivity, TProperty> > propertyExpression)
        {
            propertyExpression.IsValid().AssertTrue("Invalid property expression");

            myActivityDescriptor = activityDescriptor;
            myPropertyName       = propertyExpression.GetPropertyName();
            myPropertySetter     = propertyExpression.ConvertToSetter();
        }
Example #3
0
        public static Result <T> Of <TActivity>([NotNull] ActivityDescriptor <TActivity> descriptor)
            where TActivity : class, IActivity <T>
        {
            descriptor.AssertNotNull("descriptor != null");

            var result = new Result <T>(descriptor.NotNull().Id);

            descriptor.RegisterActivityTaskHandler(task => HandleCompletedTask(task, result));

            return(result);
        }
        public static void OnCompletionAssign <TActivity, TVariable>(
            [NotNull] this ActivityDescriptor <TActivity> descriptor, [NotNull] Variable <TVariable> variable, TVariable value)
            where TActivity : class, IActivity
        {
            descriptor.AssertNotNull("descriptor != null");
            variable.AssertNotNull("variable != null");

            descriptor.RegisterActivityTaskHandler(t =>
            {
                if (t.Status == TaskStatus.RanToCompletion)
                {
                    variable.Assign(value);
                }
            });
        }
        public static void BindToResultOf <TVariable, TActivity>(
            [NotNull] this Variable <TVariable> variable, [NotNull] ActivityDescriptor <TActivity> descriptor)
            where TActivity : class, IActivity <TVariable>
        {
            variable.AssertNotNull("variable != null");
            descriptor.AssertNotNull("descriptor != null");

            descriptor.RegisterActivityTaskHandler(t =>
            {
                if (t.Status == TaskStatus.RanToCompletion)
                {
                    variable.Assign((TVariable)t.Result);
                }
            });
        }
        public static void OnCompletionUpdate <TActivity, TActivityResult, TVariable>(
            [NotNull] this ActivityDescriptor <TActivity> descriptor, [NotNull] Variable <TVariable> variable,
            [NotNull] Func <TVariable, TActivityResult, TVariable> updateFunc)
            where TActivity : class, IActivity <TActivityResult>
        {
            descriptor.AssertNotNull("descriptor != null");
            variable.AssertNotNull("variable != null");

            descriptor.RegisterActivityTaskHandler(t =>
            {
                if (t.Status == TaskStatus.RanToCompletion)
                {
                    variable.Update(updateFunc, (TActivityResult)t.Result);
                }
            });
        }
        public void ToResultOf <TAnotherActivity>([NotNull] ActivityDescriptor <TAnotherActivity> descriptor)
            where TAnotherActivity : class, IActivity <TProperty>
        {
            descriptor.AssertNotNull("descriptor != null");

            var bindingInfo = new ResultBinding <TProperty, TAnotherActivity>(myPropertyName, descriptor);

            myActivityDescriptor.AddBindingInfo(bindingInfo);

            ActivityTaskHandler handler = task =>
            {
                if (task.Status == TaskStatus.RanToCompletion)
                {
                    myActivityDescriptor.AddInitializer(a => SetProperty(a, task.Result));
                }
            };

            descriptor.RegisterActivityTaskHandler(handler);
        }
 public ResultBinding([NotNull] string propertyName, [NotNull] ActivityDescriptor <TActivity> activity)
 {
     PropertyName = propertyName.NotNullOrEmpty("propertyName");
     Activity     = activity.NotNull();
 }
 internal ActivityNode()
 {
     myActivityDescriptor = new ActivityDescriptor <TActivity>(Id);
 }