/
Projection.cs
30 lines (29 loc) · 1.32 KB
/
Projection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using DevZest.Data.Annotations.Primitives;
using System;
using System.Linq.Expressions;
namespace DevZest.Data
{
/// <summary>
/// Represents a projection, which inherits subset of columns from model.
/// </summary>
public abstract class Projection : Model
{
/// <summary>
/// Registers a column from existing column mounter.
/// </summary>
/// <typeparam name="T">The type of projection which the column is registered on.</typeparam>
/// <typeparam name="TColumn">The type of the column.</typeparam>
/// <param name="getter">The lambda expression of the column getter.</param>
/// <param name="fromMounter">The existing column mounter.</param>
/// <exception cref="ArgumentNullException"><paramref name="getter"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="getter"/> expression is not an valid getter.</exception>
/// <exception cref="ArgumentNullException"><paramref name="fromMounter"/> is null.</exception>
[PropertyRegistration]
protected static void Register<T, TColumn>(Expression<Func<T, TColumn>> getter, Mounter<TColumn> fromMounter)
where T : Projection
where TColumn : Column, new()
{
RegisterColumn(getter, fromMounter);
}
}
}