-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnflattenContext.cs
More file actions
38 lines (31 loc) · 1.08 KB
/
Copy pathUnflattenContext.cs
File metadata and controls
38 lines (31 loc) · 1.08 KB
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
31
32
33
34
35
36
37
38
using System.Collections.Generic;
using JSONstat.Models;
namespace JSONstat.Transform;
/// <summary>
/// The context handed to the <see cref="Dataset.Unflatten{T}"/> selector for
/// each cell, mirroring the JavaScript Toolkit's <c>Unflatten</c> callback
/// arguments (coordinates, datapoint, counter, accumulator).
/// </summary>
public sealed class UnflattenContext<T>
{
private readonly List<T> _rows;
internal UnflattenContext(
IReadOnlyDictionary<string, string> coordinates,
Datum datapoint,
int n,
List<T> rows)
{
Coordinates = coordinates;
Datapoint = datapoint;
N = n;
_rows = rows;
}
/// <summary>Dimension id -> category id for the current cell.</summary>
public IReadOnlyDictionary<string, string> Coordinates { get; }
/// <summary>The value and status of the current cell.</summary>
public Datum Datapoint { get; }
/// <summary>The linear cell counter.</summary>
public int N { get; }
/// <summary>The rows accumulated so far.</summary>
public IReadOnlyList<T> Row => _rows;
}