public MappingOperationsProcessor(MappingOperationsProcessor prototype) { locFrom = prototype.locFrom; locTo = prototype.locTo; locState = prototype.locState; locException = prototype.locException; compilationContext = prototype.compilationContext; operations = prototype.operations; storedObjects = prototype.storedObjects; mappingConfigurator = prototype.mappingConfigurator; objectsMapperManager = prototype.objectsMapperManager; rootOperation = prototype.rootOperation; staticConvertersManager = prototype.staticConvertersManager; }
public MappingOperationsProcessor(MappingOperationsProcessor prototype) { LocFrom = prototype.LocFrom; LocTo = prototype.LocTo; LocState = prototype.LocState; LocException = prototype.LocException; CompilationContext = prototype.CompilationContext; Operations = prototype.Operations; StoredObjects = prototype.StoredObjects; MappingConfigurator = prototype.MappingConfigurator; ObjectsMapperManager = prototype.ObjectsMapperManager; RootOperation = prototype.RootOperation; StaticConvertersManager = prototype.StaticConvertersManager; }
public void BuildCopyImplMethod() { if (ReflectionUtils.IsNullable(_from)) { _from = Nullable.GetUnderlyingType(_from); } if (ReflectionUtils.IsNullable(_to)) { _to = Nullable.GetUnderlyingType(_to); } MethodBuilder methodBuilder = _typeBuilder.DefineMethod( "MapImpl", MethodAttributes.Public | MethodAttributes.Virtual, typeof(object), new Type[] { typeof(object), typeof(object), typeof(object) } ); ILGenerator ilGen = methodBuilder.GetILGenerator(); CompilationContext compilationContext = new CompilationContext(ilGen); AstComplexNode mapperAst = new AstComplexNode(); var locFrom = ilGen.DeclareLocal(_from); var locTo = ilGen.DeclareLocal(_to); var locState = ilGen.DeclareLocal(typeof(object)); LocalBuilder locException = null; mapperAst.Nodes.Add(BuilderUtils.InitializeLocal(locFrom, 1)); mapperAst.Nodes.Add(BuilderUtils.InitializeLocal(locTo, 2)); mapperAst.Nodes.Add(BuilderUtils.InitializeLocal(locState, 3)); #if DEBUG locException = compilationContext.ILGenerator.DeclareLocal(typeof(Exception)); #endif var mappingOperations = _mappingConfigurator.GetMappingOperations(_from, _to); StaticConvertersManager staticConverter = _mappingConfigurator.GetStaticConvertersManager(); mapperAst.Nodes.Add( new MappingOperationsProcessor() { LocException = locException, LocFrom = locFrom, LocState = locState, LocTo = locTo, ObjectsMapperManager = _objectsMapperManager, CompilationContext = compilationContext, StoredObjects = StoredObjects, Operations = mappingOperations, MappingConfigurator = _mappingConfigurator, RootOperation = _mappingConfigurator.GetRootMappingOperation(_from, _to), StaticConvertersManager = staticConverter ?? StaticConvertersManager.DefaultInstance }.ProcessOperations() ); mapperAst.Nodes.Add( new AstReturn() { ReturnType = typeof(object), ReturnValue = AstBuildHelper.ReadLocalRV(locTo) } ); mapperAst.Compile(compilationContext); }