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); } }
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)); }
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)); }