-
Notifications
You must be signed in to change notification settings - Fork 50
/
ChartMapper.cs
43 lines (39 loc) · 1.7 KB
/
ChartMapper.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
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Threading.Tasks;
using OSPSuite.Core.Chart;
namespace PKSim.Core.Snapshots.Mappers
{
public class ChartSnapshotContext : SnapshotContext
{
public IChart Chart { get; }
public ChartSnapshotContext(IChart chart, SnapshotContext baseContext) : base(baseContext)
{
Chart = chart;
}
}
public class ChartMapper : ObjectBaseSnapshotMapperBase<IChart, Chart, ChartSnapshotContext, Chart>
{
public override Task<Chart> MapToSnapshot(IChart chart, Chart snapshot)
{
MapModelPropertiesToSnapshot(chart, snapshot);
snapshot.Settings = chart.ChartSettings;
snapshot.FontAndSize = chart.FontAndSize;
snapshot.IncludeOriginData = SnapshotValueFor(chart.IncludeOriginData);
snapshot.OriginText = SnapshotValueFor(chart.OriginText);
snapshot.PreviewSettings = SnapshotValueFor(chart.PreviewSettings);
snapshot.Title = SnapshotValueFor(chart.Title);
return Task.FromResult(snapshot);
}
public override Task<IChart> MapToModel(Chart snapshot, ChartSnapshotContext snapshotContext)
{
var chart = snapshotContext.Chart;
MapSnapshotPropertiesToModel(snapshot, chart);
chart.ChartSettings.UpdatePropertiesFrom(snapshot.Settings);
chart.FontAndSize.UpdatePropertiesFrom(snapshot.FontAndSize);
chart.IncludeOriginData = snapshot.IncludeOriginData.GetValueOrDefault(chart.IncludeOriginData);
chart.OriginText = snapshot.OriginText;
chart.PreviewSettings = snapshot.PreviewSettings.GetValueOrDefault(chart.PreviewSettings);
chart.Title = ModelValueFor(snapshot.Title);
return Task.FromResult(chart);
}
}
}