public ConstructorEmitter CreateConstructor(Type[] arguments) { ArgumentUtility.CheckNotNull("arguments", arguments); ArgumentReference[] argumentReferences = ArgumentsUtil.ConvertToArgumentReference(arguments); return(CreateConstructor(argumentReferences)); }
public EasyMethod CreateMethod(string name, MethodAttributes attrs, ReturnReferenceExpression returnType, params Type[] args) { EasyMethod method = new EasyMethod(this, name, attrs, returnType, ArgumentsUtil.ConvertToArgumentReference(args)); this._methods.Add(method); return(method); }
/// <summary> /// Generates one public constructor receiving /// the <see cref="IInterceptor"/> instance and instantiating a hashtable /// </summary> protected virtual EasyConstructor GenerateConstructor(ConstructorInfo baseConstructor) { ArrayList arguments = new ArrayList(); ArgumentReference arg1 = new ArgumentReference(Context.Interceptor); ArgumentReference arg2 = new ArgumentReference(typeof(object[])); arguments.Add(arg1); ParameterInfo[] parameters = baseConstructor.GetParameters(); if (Context.HasMixins) { arguments.Add(arg2); } ArgumentReference[] originalArguments = ArgumentsUtil.ConvertToArgumentReference(parameters); arguments.AddRange(originalArguments); EasyConstructor constructor = MainTypeBuilder.CreateConstructor( (ArgumentReference[])arguments.ToArray(typeof(ArgumentReference))); GenerateConstructorCode(constructor.CodeBuilder, arg1, SelfReference.Self, arg2); constructor.CodeBuilder.InvokeBaseConstructor(baseConstructor, originalArguments); constructor.CodeBuilder.AddStatement(new ReturnStatement()); return(constructor); }
public EasyMethod CreateSetMethod(MethodAttributes attrs, params Type[] parameters) { if (_setMethod != null) { return(_setMethod); } _setMethod = new EasyMethod(_maintype, "set_" + _builder.Name, attrs, new ReturnReferenceExpression(typeof(void)), ArgumentsUtil.ConvertToArgumentReference(parameters)); return(_setMethod); }
private void ReplicateBaseTypeConstructor(ConstructorInfo constructor, Action <ConstructorEmitter> preStatementsAdder, Action <ConstructorEmitter> postStatementsAdder) { ArgumentUtility.CheckNotNull("constructor", constructor); ArgumentUtility.CheckNotNull("preStatementsAdder", preStatementsAdder); ArgumentUtility.CheckNotNull("postStatementsAdder", postStatementsAdder); ArgumentReference[] arguments = ArgumentsUtil.ConvertToArgumentReference(constructor.GetParameters()); ConstructorEmitter newConstructor = InnerEmitter.CreateConstructor(arguments); preStatementsAdder(newConstructor); Expression[] argumentExpressions = ArgumentsUtil.ConvertArgumentReferenceToExpression(arguments); newConstructor.CodeBuilder.AddStatement(new ConstructorInvocationStatement(constructor, argumentExpressions)); postStatementsAdder(newConstructor); newConstructor.CodeBuilder.AddStatement(new ReturnStatement()); }
protected virtual EasyConstructor GenerateConstructor(ConstructorInfo baseConstructor) { ArrayList list = new ArrayList(); ArgumentReference reference = new ArgumentReference(base.Context.Interceptor); ArgumentReference reference2 = new ArgumentReference(typeof(object[])); list.Add(reference); ParameterInfo[] parameters = baseConstructor.GetParameters(); if (base.Context.HasMixins) { list.Add(reference2); } ArgumentReference[] c = ArgumentsUtil.ConvertToArgumentReference(parameters); list.AddRange(c); EasyConstructor constructor = base.MainTypeBuilder.CreateConstructor((ArgumentReference[])list.ToArray(typeof(ArgumentReference))); this.GenerateConstructorCode(constructor.CodeBuilder, reference, SelfReference.Self, reference2); constructor.CodeBuilder.InvokeBaseConstructor(baseConstructor, c); constructor.CodeBuilder.AddStatement(new ReturnStatement()); return(constructor); }
public EasyMethod CreateGetMethod(MethodAttributes attrs, params Type[] parameters) { if (this._getMethod == null) { this._getMethod = new EasyMethod(this._maintype, "get_" + this._builder.Name, attrs, new ReturnReferenceExpression(this.ReturnType), ArgumentsUtil.ConvertToArgumentReference(parameters)); } return(this._getMethod); }
public EasyMethod CreateRemoveOnMethod(MethodAttributes atts, params Type[] parameters) { if (this.m_removeOnMethod == null) { this.m_removeOnMethod = new EasyMethod(this.m_maintype, "remove_" + this.Name, atts, new ReturnReferenceExpression(typeof(void)), ArgumentsUtil.ConvertToArgumentReference(parameters)); } return(this.m_removeOnMethod); }
public EasyCallable CreateCallable(Type returnType, params ParameterInfo[] args) { EasyCallable nested = new EasyCallable(this, base.IncrementAndGetCounterValue, new ReturnReferenceExpression(returnType), ArgumentsUtil.ConvertToArgumentReference(args)); base._nested.Add(nested); return(nested); }
public EasyMethod CreateAddOnMethod(MethodAttributes atts, params Type[] parameters) { if (m_addOnMethod == null) { m_addOnMethod = new EasyMethod(m_maintype, "add_" + Name, atts, new ReturnReferenceExpression(typeof(void)), ArgumentsUtil.ConvertToArgumentReference(parameters)); } return(m_addOnMethod); }