SetSignature() 공개 메소드

public SetSignature ( System returnType, System returnTypeRequiredCustomModifiers, System returnTypeOptionalCustomModifiers, System parameterTypes, System parameterTypeRequiredCustomModifiers, System parameterTypeOptionalCustomModifiers ) : void
returnType System
returnTypeRequiredCustomModifiers System
returnTypeOptionalCustomModifiers System
parameterTypes System
parameterTypeRequiredCustomModifiers System
parameterTypeOptionalCustomModifiers System
리턴 void
예제 #1
0
        public static void CopyMethodSignature(MethodInfo from, MethodBuilder to, bool substituteDeclaringType) {
            ParameterInfo[] paramInfos = from.GetParameters();
            Type[] parameterTypes = new Type[paramInfos.Length];
            Type[][] parameterRequiredModifiers = null, parameterOptionalModifiers = null;
            Type[] returnRequiredModifiers = null, returnOptionalModifiers = null;

#if !SILVERLIGHT
#if CLR2
            bool copyModopts = !from.IsGenericMethodDefinition || ModopsSupported;
#else
            bool copyModopts = true;
#endif
            if (copyModopts) {    
                returnRequiredModifiers = from.ReturnParameter.GetRequiredCustomModifiers();
                returnOptionalModifiers = from.ReturnParameter.GetOptionalCustomModifiers();
            }
#endif

            for (int i = 0; i < paramInfos.Length; i++) {
                if (substituteDeclaringType && paramInfos[i].ParameterType == from.DeclaringType) {
                    parameterTypes[i] = to.DeclaringType;
                } else {
                    parameterTypes[i] = paramInfos[i].ParameterType;
                }

#if !SILVERLIGHT
                if (copyModopts) {
                    var mods = paramInfos[i].GetRequiredCustomModifiers();
                    if (mods.Length > 0) {
                        if (parameterRequiredModifiers == null) {
                            parameterRequiredModifiers = new Type[paramInfos.Length][];
                        }

                        parameterRequiredModifiers[i] = mods;
                    }

                    mods = paramInfos[i].GetOptionalCustomModifiers();
                    if (mods.Length > 0) {
                        if (parameterOptionalModifiers == null) {
                            parameterOptionalModifiers = new Type[paramInfos.Length][];
                        }

                        parameterOptionalModifiers[i] = mods;
                    }
                }
#endif
            }

            to.SetSignature(
                from.ReturnType, returnRequiredModifiers, returnOptionalModifiers,
                parameterTypes, parameterRequiredModifiers, parameterOptionalModifiers
            );

            CopyGenericMethodAttributes(from, to);

            for (int i = 0; i < paramInfos.Length; i++) {
                to.DefineParameter(i + 1, paramInfos[i].Attributes, paramInfos[i].Name);
            }
        }