System.Reflection.RuntimeConstructorInfo.Invoke C# (CSharp) Method

Invoke() private method

private Invoke ( BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture ) : Object
invokeAttr BindingFlags
binder Binder
parameters Object
culture System.Globalization.CultureInfo
return Object
        public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
        {
            // get the declaring TypeHandle early for consistent exceptions in IntrospectionOnly context
            RuntimeTypeHandle declaringTypeHandle = m_declaringType.TypeHandle;
            
            // set one time info for invocation
            if (m_invocationFlags == INVOCATION_FLAGS_UNKNOWN) 
                m_invocationFlags = GetOneTimeFlags();

            if ((m_invocationFlags & (INVOCATION_FLAGS_NO_INVOKE | INVOCATION_FLAGS_CONTAINS_STACK_POINTERS | INVOCATION_FLAGS_NO_CTOR_INVOKE)) != 0) 
                ThrowNoInvokeException();

            if ((m_invocationFlags & (INVOCATION_FLAGS_RISKY_METHOD | INVOCATION_FLAGS_NEED_SECURITY | INVOCATION_FLAGS_IS_DELEGATE_CTOR)) != 0) 
            {
                if ((m_invocationFlags & INVOCATION_FLAGS_RISKY_METHOD) != 0) 
                    CodeAccessPermission.DemandInternal(PermissionType.ReflectionMemberAccess);
                if ((m_invocationFlags & INVOCATION_FLAGS_NEED_SECURITY)  != 0) 
                    PerformSecurityCheck(null, m_handle, m_declaringType.TypeHandle.Value, m_invocationFlags & INVOCATION_FLAGS_CONSTRUCTOR_INVOKE);
                if ((m_invocationFlags & INVOCATION_FLAGS_IS_DELEGATE_CTOR) != 0)
                    new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
            }

            // get the signature 
            int formalCount = Signature.Arguments.Length;
            int actualCount =(parameters != null) ? parameters.Length : 0;
            if (formalCount != actualCount)
                throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt"));

            // make sure the class ctor has been run
            RuntimeHelpers.RunClassConstructor(declaringTypeHandle);

            // if we are here we passed all the previous checks. Time to look at the arguments
            if (actualCount > 0) 
            {
                Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, Signature);
                Object retValue = m_handle.InvokeConstructor(arguments, Signature, declaringTypeHandle);
                // copy out. This should be made only if ByRef are present.
                for(int index = 0; index < actualCount; index++) 
                    parameters[index] = arguments[index];
                return retValue;
            }
            return m_handle.InvokeConstructor(null, Signature, declaringTypeHandle);
        }
        #endregion

Same methods

RuntimeConstructorInfo::Invoke ( Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture ) : Object