private void AddColumn <TEntity>(VerticalReportSchemaBuilder <TEntity> builder, PropertyInfo property, ReportVariableAttribute attribute, Attribute[] globalAttributes) { IReportCellsProvider <TEntity> instance = this.CreateCellsProvider <TEntity>(property, attribute); builder.AddColumn(instance); builder.AddAlias(property.Name); this.ApplyAttributes(builder, property, globalAttributes); }
private IReportCellsProvider <TEntity> CreateCellsProvider <TEntity>(PropertyInfo property, ReportVariableAttribute attribute) { ParameterExpression parameter = Expression.Parameter(typeof(TEntity), "x"); MemberExpression memberExpression = Expression.Property(parameter, typeof(TEntity), property.Name); LambdaExpression lambdaExpression = Expression.Lambda(memberExpression, parameter); IReportCellsProvider <TEntity> instance = (IReportCellsProvider <TEntity>)Activator.CreateInstance( typeof(ComputedValueReportCellsProvider <,>) .MakeGenericType(typeof(TEntity), property.PropertyType), attribute.Title, lambdaExpression.Compile()); return(instance); }