public DynamicTravellerBuilder(DynamicTravellerContext dtContext, ClassBuilder classBuilder, SerializableTypeProvider typeProvider, Type type) { _dtContext = dtContext; _classBuilder = classBuilder; _typeProvider = typeProvider; _type = type; _constructorBuilder = _classBuilder.DefineConstructor(typeof(IVisitArgsFactory)); _constructorBuilder.IL.Var.Load(_constructorBuilder.IL.Var.This()); _constructorBuilder.IL.CallBaseConstructor(typeof(object).GetConstructor(new Type[] { })); //_constructorBuilder.IL.Return(); _travelWriteMethod = _classBuilder.DefineOverloadMethod("Travel", typeof(void), new[] { typeof(IWriteVisitor), _type }); _travelReadMethod = _classBuilder.DefineOverloadMethod("Travel", typeof(void), new[] { typeof(IReadVisitor), _type }); var factory = new VisitArgsFactory(typeProvider, type); _dynamicTraveller = new DynamicTraveller(_classBuilder.Type, factory, _constructorBuilder.Reference, _travelWriteMethod.Method, _travelReadMethod.Method, dtContext.Members); }
public DynamicTravellerBuilder(DynamicTravellerContext dtContext, ClassBuilder classBuilder, SerializableTypeProvider typeProvider, Type type) { _dtContext = dtContext; _classBuilder = classBuilder; _typeProvider = typeProvider; _type = type; _constructorBuilder = _classBuilder.DefineConstructor(typeof(IVisitArgsFactory)); var baseConstructor = typeof(object).GetTypeInfo().GetConstructor(Type.EmptyTypes); var il = _constructorBuilder.IL; il.Load(ILPointer.This()); il.Emit(OpCodes.Call, baseConstructor); _travelWriteMethod = _classBuilder.DefineOverloadMethod("Travel", typeof(void), new[] { typeof(IWriteVisitor), _type }); _travelReadMethod = _classBuilder.DefineOverloadMethod("Travel", typeof(void), new[] { typeof(IReadVisitor), _type }); DynamicTraveller = new DynamicTraveller(_classBuilder.Type, _constructorBuilder.Reference, _travelWriteMethod.Method, _travelReadMethod.Method, dtContext.Members); }