private void CreateArgument(LocationReference sourceReference)
        {
            RuntimeArgument argument = new RuntimeArgument(NameGenerator.Next(), sourceReference.Type, ArgumentDirection.In);
            Argument        binding  = ActivityUtilities.CreateArgument(sourceReference.Type, ArgumentDirection.In);

            binding.Expression = ActivityUtilities.CreateLocationReferenceValue(sourceReference);
            this.Bind(binding, argument);
            this.activity.AddTempAutoGeneratedArgument(argument);
        }
 public object GetValue(RuntimeArgument runtimeArgument)
 {
     this.ThrowIfDisposed();
     if (runtimeArgument == null)
     {
         throw FxTrace.Exception.ArgumentNull("runtimeArgument");
     }
     return(this.GetValueCore <object>(runtimeArgument));
 }
        private void AddGeneratedArgument(Type argumentType, ArgumentDirection direction, ActivityWithResult expression)
        {
            Argument argument = ActivityUtilities.CreateArgument(argumentType, direction);

            argument.Expression = expression;
            RuntimeArgument runtimeArgument = this.metadata.CurrentActivity.AddTempAutoGeneratedArgument(argumentType, direction);

            Argument.TryBind(argument, runtimeArgument, this.metadata.CurrentActivity);
        }
예제 #4
0
        /// <summary>
        /// Adds the argument.
        /// </summary>
        /// <param name="argument">The argument.</param>
        public void AddArgument(RuntimeArgument argument)
        {
            this.ThrowIfDisposed();

            if (argument != null)
            {
                this.activity.AddArgument(argument, this.CreateEmptyBindings);
            }
        }
예제 #5
0
        internal bool ResolveArguments(ActivityExecutor executor, IDictionary <string, object> argumentValueOverrides, Location resultLocation, int startIndex = 0)
        {
            bool flag = true;

            if (this.Activity.SkipArgumentResolution)
            {
                using (ActivityContext context = executor.GetResolutionContext(this))
                {
                    RuntimeArgument resultRuntimeArgument = ((ActivityWithResult)this.Activity).ResultRuntimeArgument;
                    if (!resultRuntimeArgument.TryPopulateValue(this.environment, this, context, null, resultLocation, false))
                    {
                        flag = false;
                        Location specificLocation = this.environment.GetSpecificLocation(resultRuntimeArgument.Id);
                        executor.ScheduleExpression(resultRuntimeArgument.BoundArgument.Expression, this, context.Environment, specificLocation.CreateReference(true));
                    }
                    goto Label_0166;
                }
            }
            IList <RuntimeArgument> runtimeArguments = this.Activity.RuntimeArguments;
            int count = runtimeArguments.Count;

            if (count > 0)
            {
                using (ActivityContext context2 = executor.GetResolutionContext(this))
                {
                    for (int i = startIndex; i < count; i++)
                    {
                        RuntimeArgument argument2 = runtimeArguments[i];
                        object          obj2      = null;
                        if (argumentValueOverrides != null)
                        {
                            argumentValueOverrides.TryGetValue(argument2.Name, out obj2);
                        }
                        if (!argument2.TryPopulateValue(this.environment, this, context2, obj2, resultLocation, false))
                        {
                            flag = false;
                            int nextArgumentIndex = i + 1;
                            if (nextArgumentIndex < runtimeArguments.Count)
                            {
                                ResolveNextArgumentWorkItem workItem = executor.ResolveNextArgumentWorkItemPool.Acquire();
                                workItem.Initialize(this, nextArgumentIndex, argumentValueOverrides, resultLocation);
                                executor.ScheduleItem(workItem);
                            }
                            Location location2 = this.environment.GetSpecificLocation(argument2.Id);
                            executor.ScheduleExpression(argument2.BoundArgument.Expression, this, context2.Environment, location2.CreateReference(true));
                            goto Label_0166;
                        }
                    }
                }
            }
Label_0166:
            if (flag && (startIndex == 0))
            {
                this.substate = Substate.ResolvingVariables;
            }
            return(flag);
        }
예제 #6
0
        internal static void Bind(Argument binding, RuntimeArgument argument)
        {
            if (binding != null)
            {
                Fx.Assert(binding.Direction == argument.Direction, "The directions must match.");
                Fx.Assert(binding.ArgumentType == argument.Type, "The types must match.");

                binding.RuntimeArgument = argument;
            }

            argument.BoundArgument = binding;
        }
 private bool IsBoundArgumentCorrect(RuntimeArgument argument, bool createEmptyBindings)
 {
     if (createEmptyBindings)
     {
         return(object.ReferenceEquals(argument.BoundArgument, this.Result));
     }
     if (this.Result != null)
     {
         return(object.ReferenceEquals(argument.BoundArgument, this.Result));
     }
     return(true);
 }
 public static RuntimeArgument FindArgument(string argumentName, Activity argumentConsumer)
 {
     if ((argumentConsumer.MemberOf != null) && (argumentConsumer.MemberOf.Owner != null))
     {
         Activity owner = argumentConsumer.MemberOf.Owner;
         for (int i = 0; i < owner.RuntimeArguments.Count; i++)
         {
             RuntimeArgument argument = owner.RuntimeArguments[i];
             if (argument.Name == argumentName)
             {
                 return(argument);
             }
         }
     }
     return(null);
 }
        internal sealed override void OnInternalCacheMetadata(bool createEmptyBindings)
        {
            this.OnInternalCacheMetadataExceptResult(createEmptyBindings);
            bool flag = false;
            IList <RuntimeArgument> runtimeArguments = base.RuntimeArguments;
            int count = 0;

            if (runtimeArguments != null)
            {
                count = runtimeArguments.Count;
                for (int i = 0; i < count; i++)
                {
                    RuntimeArgument argument = runtimeArguments[i];
                    if (argument.Name == "Result")
                    {
                        flag = true;
                        if ((argument.Type != typeof(TResult)) || (argument.Direction != ArgumentDirection.Out))
                        {
                            base.AddTempValidationError(new ValidationError(System.Activities.SR.ResultArgumentHasRequiredTypeAndDirection(typeof(TResult), argument.Direction, argument.Type)));
                        }
                        else if (!this.IsBoundArgumentCorrect(argument, createEmptyBindings))
                        {
                            base.AddTempValidationError(new ValidationError(System.Activities.SR.ResultArgumentMustBeBoundToResultProperty));
                        }
                        else
                        {
                            base.ResultRuntimeArgument = argument;
                        }
                        break;
                    }
                }
            }
            if (!flag)
            {
                base.ResultRuntimeArgument = new RuntimeArgument("Result", typeof(TResult), ArgumentDirection.Out);
                if ((this.Result == null) && createEmptyBindings)
                {
                    this.Result = new OutArgument <TResult>();
                }
                Argument.Bind(this.Result, base.ResultRuntimeArgument);
                base.AddArgument(base.ResultRuntimeArgument, createEmptyBindings);
            }
        }
 private static void ProcessArguments(Activity parent, IList <RuntimeArgument> arguments, bool addChildren, ref ActivityLocationReferenceEnvironment environment, ref int nextEnvironmentId, ref ChildActivity nextActivity, ref Stack <ChildActivity> activitiesRemaining, ref IList <ValidationError> validationErrors)
 {
     if (arguments.Count > 0)
     {
         if (environment == null)
         {
             environment = new ActivityLocationReferenceEnvironment(parent.GetParentEnvironment());
         }
         for (int i = 0; i < arguments.Count; i++)
         {
             RuntimeArgument locationReference = arguments[i];
             if (locationReference.InitializeRelationship(parent, ref validationErrors))
             {
                 locationReference.Id = nextEnvironmentId;
                 nextEnvironmentId++;
                 environment.Declare(locationReference, locationReference.Owner, ref validationErrors);
                 if (addChildren)
                 {
                     SetupForProcessing(locationReference, ref nextActivity, ref activitiesRemaining);
                 }
             }
         }
     }
 }
예제 #11
0
        public void Bind(Argument binding, RuntimeArgument argument)
        {
            ThrowIfDisposed();

            Argument.TryBind(binding, argument, this.activity);
        }
예제 #12
0
 public object GetValue(RuntimeArgument runtimeArgument)
 {
     throw new NotImplementedException();
 }
예제 #13
0
 public void Bind(Argument binding, RuntimeArgument argument)
 {
     throw new NotImplementedException();
 }
예제 #14
0
 public void AddArgument(RuntimeArgument argument)
 {
     throw new NotImplementedException();
 }
예제 #15
0
        public static IEnumerable <Activity> GetActivities(Activity activity)
        {
            int iteratorVariable0;

            if (activity == null)
            {
                throw FxTrace.Exception.ArgumentNull("activity");
            }
            if (!activity.IsMetadataCached)
            {
                IList <ValidationError> validationErrors = null;
                ActivityUtilities.CacheRootMetadata(activity, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);
                ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.RuntimeArguments.Count; iteratorVariable0++)
            {
                RuntimeArgument iteratorVariable1 = activity.RuntimeArguments[iteratorVariable0];
                if ((iteratorVariable1.BoundArgument != null) && (iteratorVariable1.BoundArgument.Expression != null))
                {
                    yield return(iteratorVariable1.BoundArgument.Expression);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.RuntimeVariables.Count; iteratorVariable0++)
            {
                Variable iteratorVariable2 = activity.RuntimeVariables[iteratorVariable0];
                if (iteratorVariable2.Default != null)
                {
                    yield return(iteratorVariable2.Default);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImplementationVariables.Count; iteratorVariable0++)
            {
                Variable iteratorVariable3 = activity.ImplementationVariables[iteratorVariable0];
                if (iteratorVariable3.Default != null)
                {
                    yield return(iteratorVariable3.Default);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.Children.Count; iteratorVariable0++)
            {
                yield return(activity.Children[iteratorVariable0]);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImportedChildren.Count; iteratorVariable0++)
            {
                yield return(activity.ImportedChildren[iteratorVariable0]);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImplementationChildren.Count; iteratorVariable0++)
            {
                yield return(activity.ImplementationChildren[iteratorVariable0]);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.Delegates.Count; iteratorVariable0++)
            {
                ActivityDelegate iteratorVariable4 = activity.Delegates[iteratorVariable0];
                if (iteratorVariable4.Handler != null)
                {
                    yield return(iteratorVariable4.Handler);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImportedDelegates.Count; iteratorVariable0++)
            {
                ActivityDelegate iteratorVariable5 = activity.ImportedDelegates[iteratorVariable0];
                if (iteratorVariable5.Handler != null)
                {
                    yield return(iteratorVariable5.Handler);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImplementationDelegates.Count; iteratorVariable0++)
            {
                ActivityDelegate iteratorVariable6 = activity.ImplementationDelegates[iteratorVariable0];
                if (iteratorVariable6.Handler != null)
                {
                    yield return(iteratorVariable6.Handler);
                }
            }
        }
예제 #16
0
 /// <summary>
 /// Gets the ignorable result location.
 /// </summary>
 /// <param name="resultArgument">The result argument.</param>
 /// <returns>Location.</returns>
 internal Location GetIgnorableResultLocation(RuntimeArgument resultArgument) =>
 this.CurrentExecutor.GetIgnorableResultLocation(resultArgument);
 internal override bool IsResultArgument(RuntimeArgument argument)
 {
     return(object.ReferenceEquals(argument, base.ResultRuntimeArgument));
 }
예제 #18
0
 internal Location GetIgnorableResultLocation(RuntimeArgument resultArgument)
 {
     return(this.executor.GetIgnorableResultLocation(resultArgument));
 }
        public static IEnumerable <Activity> GetActivities(Activity activity)
        {
            if (activity == null)
            {
                throw FxTrace.Exception.ArgumentNull("activity");
            }

            if (!activity.IsMetadataCached)
            {
                IList <ValidationError> validationErrors = null;

                ActivityUtilities.CacheRootMetadata(activity, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);

                ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
            }

            int i = 0;

            for (; i < activity.RuntimeArguments.Count; i++)
            {
                RuntimeArgument argument = activity.RuntimeArguments[i];

                if (argument.BoundArgument != null && argument.BoundArgument.Expression != null)
                {
                    yield return(argument.BoundArgument.Expression);
                }
            }

            for (i = 0; i < activity.RuntimeVariables.Count; i++)
            {
                Variable variable = activity.RuntimeVariables[i];

                if (variable.Default != null)
                {
                    yield return(variable.Default);
                }
            }

            for (i = 0; i < activity.ImplementationVariables.Count; i++)
            {
                Variable variable = activity.ImplementationVariables[i];

                if (variable.Default != null)
                {
                    yield return(variable.Default);
                }
            }

            for (i = 0; i < activity.Children.Count; i++)
            {
                yield return(activity.Children[i]);
            }

            for (i = 0; i < activity.ImportedChildren.Count; i++)
            {
                yield return(activity.ImportedChildren[i]);
            }

            for (i = 0; i < activity.ImplementationChildren.Count; i++)
            {
                yield return(activity.ImplementationChildren[i]);
            }

            for (i = 0; i < activity.Delegates.Count; i++)
            {
                ActivityDelegate activityDelegate = activity.Delegates[i];

                if (activityDelegate.Handler != null)
                {
                    yield return(activityDelegate.Handler);
                }
            }

            for (i = 0; i < activity.ImportedDelegates.Count; i++)
            {
                ActivityDelegate activityDelegate = activity.ImportedDelegates[i];

                if (activityDelegate.Handler != null)
                {
                    yield return(activityDelegate.Handler);
                }
            }

            for (i = 0; i < activity.ImplementationDelegates.Count; i++)
            {
                ActivityDelegate activityDelegate = activity.ImplementationDelegates[i];

                if (activityDelegate.Handler != null)
                {
                    yield return(activityDelegate.Handler);
                }
            }
        }