OnlyStaticMethodsHaveNullInstance() static private method

ArgumentException with message like "Static method requires null instance, non-static method requires non-null instance."
static private OnlyStaticMethodsHaveNullInstance ( ) : Exception
return Exception
コード例 #1
0
ファイル: IndexExpression.net30.cs プロジェクト: lin5/Theraot
        private static void ValidateAccessor(Expression instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection <Expression> arguments)
        {
            ContractUtils.RequiresNotNull(arguments, "arguments");

            ValidateMethodInfo(method);
            if ((method.CallingConvention & CallingConventions.VarArgs) != 0)
            {
                throw Error.AccessorsCannotHaveVarArgs();
            }

            if (method.IsStatic)
            {
                if (instance != null)
                {
                    throw Error.OnlyStaticMethodsHaveNullInstance();
                }
            }
            else
            {
                if (instance == null)
                {
                    throw Error.OnlyStaticMethodsHaveNullInstance();
                }

                RequiresCanRead(instance, "instance");
                ValidateCallInstanceType(instance.Type, method);
            }

            ValidateAccessorArgumentTypes(method, indexes, ref arguments);
        }