public static MutableMethodInfo AddMethod( this MutableType declaringType, string name, MethodAttributes attributes = MethodAttributes.Public, Type returnType = null, IEnumerable <ParameterDeclaration> parameters = null, Func <MethodBodyCreationContext, Expression> bodyProvider = null) { ArgumentUtility.CheckNotNullOrEmpty("name", name); returnType = returnType ?? typeof(void); parameters = parameters ?? ParameterDeclaration.None; // Body provider may be null (for abstract methods). return(declaringType.AddMethod(name, attributes, GenericParameterDeclaration.None, ctx => returnType, ctx => parameters, bodyProvider)); }
public static MutableMethodInfo AddAbstractMethod( this MutableType declaringType, string name, MethodAttributes attributes = MethodAttributes.Public, Type returnType = null, IEnumerable <ParameterDeclaration> parameters = null) { ArgumentUtility.CheckNotNull("declaringType", declaringType); ArgumentUtility.CheckNotNullOrEmpty("name", name); returnType = returnType ?? typeof(void); parameters = parameters ?? ParameterDeclaration.None; var abstractAttributes = attributes.Set(MethodAttributes.Abstract | MethodAttributes.Virtual); return(declaringType.AddMethod(name, abstractAttributes, returnType, parameters, bodyProvider: null)); }
public static MutableMethodInfo AddMethod( this MutableType declaringType, string name, MethodAttributes attributes, MethodDeclaration methodDeclaration, Func <MethodBodyCreationContext, Expression> bodyProvider) { ArgumentUtility.CheckNotNull("declaringType", declaringType); ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckNotNull("methodDeclaration", methodDeclaration); // Body provider may be null (for abstract methods). var md = methodDeclaration; return(declaringType.AddMethod(name, attributes, md.GenericParameters, md.ReturnTypeProvider, md.ParameterProvider, bodyProvider)); }