System.Linq.Expressions.Error.AccessorsCannotHaveByRefArgs C# (CSharp) Метод

AccessorsCannotHaveByRefArgs() статический приватный Метод

ArgumentException with message like "Accessor indexes cannot be passed ByRef."
static private AccessorsCannotHaveByRefArgs ( string paramName ) : Exception
paramName string
Результат System.Exception
        internal static Exception AccessorsCannotHaveByRefArgs(string paramName)
        {
            return new ArgumentException(Strings.AccessorsCannotHaveByRefArgs, paramName);
        }
        /// <summary>

Same methods

Error::AccessorsCannotHaveByRefArgs ( string paramName, int index ) : Exception

Usage Example

Пример #1
0
        private static void ValidateAccessorArgumentTypes(MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection <Expression> arguments)
        {
            if (indexes.Length > 0)
            {
                if (indexes.Length != arguments.Count)
                {
                    throw Error.IncorrectNumberOfMethodCallArguments(method);
                }
                Expression[] newArgs = null;
                var          n       = indexes.Length;
                for (var i = 0; i < n; i++)
                {
                    var arg = arguments[i];
                    var pi  = indexes[i];
                    RequiresCanRead(arg, "arguments");

                    var pType = pi.ParameterType;
                    if (pType.IsByRef)
                    {
                        throw Error.AccessorsCannotHaveByRefArgs();
                    }

                    TypeHelper.ValidateType(pType);

                    if (!TypeHelper.AreReferenceAssignable(pType, arg.Type))
                    {
                        if (!TryQuote(pType, ref arg))
                        {
                            throw Error.ExpressionTypeDoesNotMatchMethodParameter(arg.Type, pType, method);
                        }
                    }
                    if (newArgs == null && arg != arguments[i])
                    {
                        newArgs = new Expression[arguments.Count];
                        for (var j = 0; j < i; j++)
                        {
                            newArgs[j] = arguments[j];
                        }
                    }
                    if (newArgs != null)
                    {
                        newArgs[i] = arg;
                    }
                }
                if (newArgs != null)
                {
                    arguments = new TrueReadOnlyCollection <Expression>(newArgs);
                }
            }
            else if (arguments.Count > 0)
            {
                throw Error.IncorrectNumberOfMethodCallArguments(method);
            }
        }
All Usage Examples Of System.Linq.Expressions.Error::AccessorsCannotHaveByRefArgs
Error