예제 #1
0
 private void EmitMap(CompilationContext context)
 {
     if (_beforeMapBuilder != null)
     {
         context.LoadSource(LoadPurpose.Parameter);
         context.LoadTarget(LoadPurpose.Parameter);
         _beforeMapBuilder.Emit(context);
     }
     if (_customInvokerBuilder != null)
     {
         context.LoadSource(LoadPurpose.Parameter);
         context.LoadTarget(LoadPurpose.Parameter);
         _customInvokerBuilder.Emit(context);
     }
     else
     {
         foreach (var mapper in _memberMappers)
         {
             mapper.Emit(context);
         }
     }
     if (_afterMapBuilder != null)
     {
         context.LoadSource(LoadPurpose.Parameter);
         context.LoadTarget(LoadPurpose.Parameter);
         _afterMapBuilder.Emit(context);
     }
 }
예제 #2
0
 public void Emit(CompilationContext context)
 {
     context.LoadSource(LoadPurpose.Parameter);
     context.CurrentType = typeof(TSource);
     _invokerBuilder.Emit(context);
     context.CurrentType = typeof(TTarget);
 }
예제 #3
0
        internal override void EmitGetter(CompilationContext context)
        {
            var getMethod = _property.GetGetMethod(true);

            context.LoadSource(LoadPurpose.MemberAccess);
            context.EmitCall(getMethod);
            context.CurrentType = MemberType;
        }
예제 #4
0
 public override void Emit(Type sourceType, Type targetType, CompilationContext context)
 {
     context.LoadSource(LoadPurpose.Parameter);
     context.CurrentType = sourceType;
     context.EmitCast(typeof(IEnumerable <>).MakeGenericType(_sourceElementType));
     context.LoadTarget(LoadPurpose.Parameter);
     context.CurrentType = targetType;
     context.EmitCast(typeof(IEnumerable <>).MakeGenericType(_targetElementType));
     _invokerBuilder.Emit(context);
 }
예제 #5
0
 protected override void EmitSource(CompilationContext context)
 {
     context.LoadSource(LoadPurpose.Parameter);
     _invokerBuilder.Emit(context);
     context.CurrentType = SourceType;
 }
예제 #6
0
 internal override void EmitGetter(CompilationContext context)
 {
     context.LoadSource(LoadPurpose.MemberAccess);
     context.Emit(OpCodes.Ldfld, _field);
     context.CurrentType = _field.FieldType;
 }