コード例 #1
0
        public virtual IArgumentConstraint GetArgumentConstraint(ParsedArgumentExpression argument)
        {
            if (IsParamArrayExpression(argument))
            {
                return this.CreateParamArrayConstraint((NewArrayExpression)argument.Expression);
            }

            var isByRefArgument = IsByRefArgument(argument);

            object argumentValue;
            var constraint = this.GetArgumentConstraintFromExpression(argument.Expression, out argumentValue);
            if (isByRefArgument)
            {
                if (IsOutArgument(argument))
                {
                    constraint = new OutArgumentConstraint(argumentValue);
                }
                else
                {
                    constraint = new RefArgumentConstraint(constraint, argumentValue);
                }
            }

            return constraint;
        }
コード例 #2
0
        public virtual IArgumentConstraint GetArgumentConstraint(ParsedArgumentExpression argument)
        {
            var parameterType = argument.ArgumentInformation.ParameterType;

            if (IsParamArrayExpression(argument))
            {
                return(this.CreateParamArrayConstraint((NewArrayExpression)argument.Expression, parameterType));
            }

            var isOutOrRefArgument = argument.ArgumentInformation.IsOutOrRef();

            var constraint = this.GetArgumentConstraintFromExpression(argument.Expression, parameterType, out var argumentValue);

            if (isOutOrRefArgument)
            {
                if (IsOutArgument(argument))
                {
                    constraint = new OutArgumentConstraint(argumentValue);
                }
                else
                {
                    constraint = new RefArgumentConstraint(constraint, argumentValue);
                }
            }

            return(constraint);
        }
コード例 #3
0
        public virtual IArgumentConstraint GetArgumentConstraint(ParsedArgumentExpression argument)
        {
            if (IsParamArrayExpression(argument))
            {
                return(this.CreateParamArrayConstraint((NewArrayExpression)argument.Expression));
            }

            var isByRefArgument = IsByRefArgument(argument);

            object argumentValue;
            var    constraint = this.GetArgumentConstraintFromExpression(argument.Expression, out argumentValue);

            if (isByRefArgument)
            {
                if (IsOutArgument(argument))
                {
                    constraint = new OutArgumentConstraint(argumentValue);
                }
                else
                {
                    constraint = new RefArgumentConstraint(constraint, argumentValue);
                }
            }

            return(constraint);
        }
        public virtual IArgumentConstraint GetArgumentConstraint(ParsedArgumentExpression argument)
        {
            if (IsParamArrayExpression(argument))
            {
                return this.CreateParamArrayConstraint((NewArrayExpression)argument.Expression);
            }

            return this.GetArgumentConstraintFromExpression(argument.Expression);
        }
コード例 #5
0
        public virtual IArgumentConstraint GetArgumentConstraint(ParsedArgumentExpression argument)
        {
            if (IsParamArrayExpression(argument))
            {
                return(this.CreateParamArrayConstraint((NewArrayExpression)argument.Expression));
            }

            return(this.GetArgumentConstraintFromExpression(argument.Expression));
        }
コード例 #6
0
        private static ParsedArgumentExpression[] CreateParsedArgumentExpressions(IList <Expression> expressionArguments, ParameterInfo[] parameters)
        {
            var argumentsExpressions = new ParsedArgumentExpression[expressionArguments.Count];

            for (int i = 0; i < argumentsExpressions.Length; i++)
            {
                argumentsExpressions[i] = new ParsedArgumentExpression(expressionArguments[i], parameters[i]);
            }

            return(argumentsExpressions);
        }
コード例 #7
0
        public virtual IArgumentConstraint GetArgumentConstraint(ParsedArgumentExpression argument)
        {
            if (IsParamArrayExpression(argument))
            {
                return(this.CreateParamArrayConstraint((NewArrayExpression)argument.Expression));
            }

            if (IsOutArgument(argument))
            {
                return(new OutArgumentConstraint(argument.Value));
            }

            var constraint = this.GetArgumentConstraintFromExpression(argument.Expression);

            if (IsRefArgument(argument))
            {
                constraint = new RefArgumentConstraint(constraint, argument.Value);
            }

            return(constraint);
        }
コード例 #8
0
        public virtual IArgumentConstraint GetArgumentConstraint(ParsedArgumentExpression argument)
        {
            if (IsParamArrayExpression(argument))
            {
                return this.CreateParamArrayConstraint((NewArrayExpression)argument.Expression);
            }

            if (IsOutArgument(argument))
            {
                return new OutArgumentConstraint(argument.Value);
            }

            var constraint = this.GetArgumentConstraintFromExpression(argument.Expression);

            if (IsRefArgument(argument))
            {
                constraint = new RefArgumentConstraint(constraint, argument.Value);
            }

            return constraint;
        }
コード例 #9
0
 private static bool IsOutArgument(ParsedArgumentExpression argument)
 {
     return(argument.ArgumentInformation.IsOut);
 }
コード例 #10
0
 private static bool IsTaggedWithParamArrayAttribute(ParsedArgumentExpression argument)
 {
     return(argument.ArgumentInformation.IsDefined(typeof(ParamArrayAttribute), true));
 }
コード例 #11
0
 private static bool IsParamArrayExpression(ParsedArgumentExpression argument)
 {
     return(argument.Expression is NewArrayExpression && IsTaggedWithParamArrayAttribute(argument));
 }
 private static bool IsByRefArgument(ParsedArgumentExpression argument)
 {
     return(argument.ArgumentInformation.ParameterType.IsByRef);
 }
コード例 #13
0
 private static bool IsByRefArgument(ParsedArgumentExpression argument)
 {
     return argument.ArgumentInformation.ParameterType.IsByRef;
 }
コード例 #14
0
 private static bool IsOutArgument(ParsedArgumentExpression argument)
 {
     return argument.ArgumentInformation.IsOut;
 }
コード例 #15
0
 private static bool IsParamArrayExpression(ParsedArgumentExpression argument)
 {
     return IsTaggedWithParamArrayAttribute(argument) && argument.Expression is NewArrayExpression;
 }
コード例 #16
0
 private static bool IsTaggedWithParamArrayAttribute(ParsedArgumentExpression argument)
 {
     return argument.ArgumentInformation.GetCustomAttributes(typeof(ParamArrayAttribute), true).Any();
 }
 private static bool IsTaggedWithParamArrayAttribute(ParsedArgumentExpression argument)
 {
     return(argument.ArgumentInformation.GetCustomAttributes(typeof(ParamArrayAttribute), true).Any());
 }