예제 #1
0
 private void AddCloneExpressions <TEntity>(IExpressionBuilder expressionBuilder, CloneExpressionContext parameters)
 {
     parameters.TargetEntity = expressionBuilder.CreateObject <TEntity>(nameof(CloneExpressionContext.TargetEntity));
     foreach (PropertyInfo cloneableProperty in CloneableProperties(typeof(TEntity)))
     {
         CloneProperty(expressionBuilder, parameters, cloneableProperty);
     }
 }
예제 #2
0
 private void AddArrayExpressions <TEntity>(IExpressionBuilder expressionBuilder, CloneExpressionContext context)
 {
     context.TargetEntity = expressionBuilder.CreateObject <TEntity>(
         nameof(CloneExpressionContext.TargetEntity),
         new[] { typeof(int) },
         new[] { ExpressionFactory.Call(context.SourceEntity, ArrayLengthProperty.GetMethod) });
     expressionBuilder.For(context.SourceEntity, CloneArrayElementDelegate(context));
 }
예제 #3
0
        private void AddListExpressions <TEntity>(IExpressionBuilder expressionBuilder, CloneExpressionContext context)
        {
            PropertyInfo listCountProperty = context
                                             .SourceEntity
                                             .Type
                                             .GetProperty(nameof(List <TEntity> .Count));

            context.TargetEntity = expressionBuilder.CreateObject <TEntity>(
                nameof(CloneExpressionContext.TargetEntity),
                new[] { typeof(int) },
                new[] { ExpressionFactory.Call(context.SourceEntity, listCountProperty.GetMethod) });
            expressionBuilder.For(context.SourceEntity, CloneListElementDelegate(expressionBuilder, context));
        }