Пример #1
0
        private object DoInvoke(object? obj, BindingFlags invokeAttr, Binder? binder, object?[]? parameters, CultureInfo? culture)
        {
            if (binder == null)
                binder = Type.DefaultBinder;

            ParameterInfo[] pinfo = MonoMethodInfo.GetParametersInfo(mhandle, this);

            RuntimeMethodInfo.ConvertValues(binder, parameters, pinfo, culture, invokeAttr);

            if (obj == null && DeclaringType.ContainsGenericParameters)
                throw new MemberAccessException("Cannot create an instance of " + DeclaringType + " because Type.ContainsGenericParameters is true.");

            if ((invokeAttr & BindingFlags.CreateInstance) != 0 && DeclaringType.IsAbstract)
            {
                throw new MemberAccessException(string.Format("Cannot create an instance of {0} because it is an abstract class", DeclaringType));
            }

            return InternalInvoke(obj, parameters, (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0)!;
        }