コード例 #1
0
        private static void AssertIsCodeActivity(Activity activity)
        {
            Type codeActivityOfTType = null;
            ActivityWithResult activityWithResult = activity as ActivityWithResult;

            if (activityWithResult != null)
            {
                codeActivityOfTType = typeof(CodeActivity <>).MakeGenericType(activityWithResult.ResultType);
            }
            Fx.Assert(activity is CodeActivity || (codeActivityOfTType != null && codeActivityOfTType.GetTypeInfo().IsAssignableFrom(activity.GetType().GetTypeInfo())), "Expected CodeActivity or CodeActivity<T>");
        }
コード例 #2
0
        internal void Validate(Activity owner, ref IList <ValidationError> validationErrors)
        {
            if (this.Expression != null)
            {
                if (this.Expression.Result != null && !this.Expression.Result.IsEmpty)
                {
                    ValidationError validationError = new ValidationError(SR.ResultCannotBeSetOnArgumentExpressions, false, this.RuntimeArgument.Name, owner);
                    ActivityUtilities.Add(ref validationErrors, validationError);
                }

                ActivityWithResult actualExpression = this.Expression;

                if (actualExpression is IExpressionWrapper)
                {
                    actualExpression = ((IExpressionWrapper)actualExpression).InnerExpression;
                }

                switch (this.Direction)
                {
                case ArgumentDirection.In:
                    if (actualExpression.ResultType != this.ArgumentType)
                    {
                        ActivityUtilities.Add(
                            ref validationErrors,
                            new ValidationError(SR.ArgumentValueExpressionTypeMismatch(this.ArgumentType, actualExpression.ResultType), false, this.RuntimeArgument.Name, owner));
                    }
                    break;

                case ArgumentDirection.InOut:
                case ArgumentDirection.Out:
                    Type locationType;
                    if (!ActivityUtilities.IsLocationGenericType(actualExpression.ResultType, out locationType) ||
                        locationType != this.ArgumentType)
                    {
                        Type expectedType = ActivityUtilities.CreateActivityWithResult(ActivityUtilities.CreateLocation(this.ArgumentType));
                        ActivityUtilities.Add(
                            ref validationErrors,
                            new ValidationError(SR.ArgumentLocationExpressionTypeMismatch(expectedType.FullName, actualExpression.GetType().FullName), false, this.RuntimeArgument.Name, owner));
                    }
                    break;
                }
            }
        }
コード例 #3
0
        internal bool InitializeRelationship(Activity parent, bool isPublic, ref IList <ValidationError> validationErrors)
        {
            if (_cacheId == parent.CacheId)
            {
                if (this.Owner != null)
                {
                    ValidationError validationError = new ValidationError(SR.VariableAlreadyInUseOnActivity(this.Name, parent.DisplayName, this.Owner.DisplayName), false, this.Name, parent);
                    ActivityUtilities.Add(ref validationErrors, validationError);

                    // Get out early since we've already initialized this variable.
                    return(false);
                }
            }

            this.Owner    = parent;
            _cacheId      = parent.CacheId;
            this.IsPublic = isPublic;

            if (this.Default != null)
            {
                ActivityWithResult expression = this.Default;

                if (expression is Argument.IExpressionWrapper)
                {
                    expression = ((Argument.IExpressionWrapper)expression).InnerExpression;
                }

                if (expression.ResultType != this.Type)
                {
                    ActivityUtilities.Add(
                        ref validationErrors,
                        new ValidationError(SR.VariableExpressionTypeMismatch(this.Name, this.Type, expression.ResultType), false, this.Name, parent));
                }

                return(this.Default.InitializeRelationship(this, isPublic, ref validationErrors));
            }

            return(true);
        }
コード例 #4
0
 public ActivityWithResultWrapper(ActivityWithResult expression)
 {
     this.expression = expression;
 }
        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);
        }
        internal void CreateLocationArgument(LocationReference sourceReference, bool useLocationReferenceValue = false)
        {
            ActivityWithResult expression = ActivityUtilities.CreateLocationAccessExpression(sourceReference, true, useLocationReferenceValue);

            AddGeneratedArgument(expression.ResultType, ArgumentDirection.In, expression);
        }