Exemplo n.º 1
0
        object DoInvoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
        {
            if (binder == null)
            {
                binder = Type.DefaultBinder;
            }

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

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

#if !NET_2_1
            if (SecurityManager.SecurityEnabled)
            {
                // sadly Attributes doesn't tell us which kind of security action this is so
                // we must do it the hard way - and it also means that we can skip calling
                // Attribute (which is another an icall)
                SecurityManager.ReflectedLinkDemandInvoke(this);
            }
#endif

            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));
        }
Exemplo n.º 2
0
        object DoInvoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
        {
            if (binder == null)
            {
                binder = Type.DefaultBinder;
            }

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

            MonoMethod.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));
        }