private void GenerateConstructor() { ArgumentReference reference = new ArgumentReference(typeof(object)); ArgumentReference reference2 = new ArgumentReference(typeof(IntPtr)); this._constructor = base.CreateRuntimeConstructor(new ArgumentReference[] { reference, reference2 }); }
public EasyConstructor CreateConstructor(params ArgumentReference[] arguments) { EasyConstructor constructor = new EasyConstructor(this, arguments); this._constructors.Add(constructor); return(constructor); }
/// <summary> /// /// </summary> protected void GenerateSerializationConstructor() { ArgumentReference owner = new ArgumentReference(typeof(SerializationInfo)); ArgumentReference reference2 = new ArgumentReference(typeof(StreamingContext)); EasyConstructor constructor = base.MainTypeBuilder.CreateConstructor(new ArgumentReference[] { owner, reference2 }); constructor.CodeBuilder.AddStatement(new ExpressionStatement(new ConstructorInvocationExpression(this._serializationConstructor, new Expression[] { owner.ToExpression(), reference2.ToExpression() }))); Type[] types = new Type[] { typeof(string), typeof(Type) }; MethodInfo method = typeof(SerializationInfo).GetMethod("GetValue", types); VirtualMethodInvocationExpression expression = new VirtualMethodInvocationExpression(owner, method, new Expression[] { new FixedReference("__interceptor").ToExpression(), new TypeTokenExpression(base.Context.Interceptor) }); VirtualMethodInvocationExpression expression2 = new VirtualMethodInvocationExpression(owner, method, new Expression[] { new FixedReference("__mixins").ToExpression(), new TypeTokenExpression(typeof(object[])) }); constructor.CodeBuilder.AddStatement(new AssignStatement(base.InterceptorField, expression)); constructor.CodeBuilder.AddStatement(new AssignStatement(base.CacheField, new NewInstanceExpression(typeof(HybridDictionary).GetConstructor(new Type[0]), new Expression[0]))); constructor.CodeBuilder.AddStatement(new AssignStatement(base.MixinField, expression2)); foreach (CallableField field in base._cachedFields) { field.WriteInitialization(constructor.CodeBuilder, SelfReference.Self, base.MixinField); } constructor.CodeBuilder.AddStatement(new ReturnStatement()); }
/// <summary> /// /// </summary> /// <param name="baseConstructor"></param> /// <returns></returns> 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 void Add(EasyConstructor constructor) { base.InnerList.Add(constructor); }