-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperationsTracker.cs
More file actions
134 lines (117 loc) · 3.69 KB
/
OperationsTracker.cs
File metadata and controls
134 lines (117 loc) · 3.69 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using PCAxis.Query.Serializers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PCAxis.Paxiom.Operations;
namespace PCAxis.Query
{
/// <summary>
/// Tracks made operations
/// </summary>
public class OperationsTracker
{
private List<WorkStep> _steps;
public OperationsTracker()
{
_steps = new List<WorkStep>();
}
public OperationsTracker(WorkStep[] workStep)
{
_steps = new List<WorkStep>();
_steps.AddRange(workStep);
}
public bool RemoveLastStep()
{
_steps = _steps.Take(_steps.Count() - 1).ToList();
return true;
}
/// <summary>
/// Resets the list of operations
/// </summary>
public void Reset()
{
_steps.Clear();
}
public bool AddStep(string type, object opDescription)
{
IOperationSerializer ser = null;
ser = CreateSerializer(type);
_steps.Add(ser.Serialize(opDescription));
return true;
}
/// <summary>
/// Indicates that operations where text can be changes has been executed.
/// </summary>
public bool IsUnsafe { get; set; }
/// <summary>
/// Indicates that an operation is dependent on time
/// </summary>
public bool IsTimeDependent { get; set; }
public static IOperationSerializer CreateSerializer(string type)
{
IOperationSerializer ser = null;
if (type == OperationConstants.PIVOT)
{
ser = new PivotSerializer();
}
else if (type == OperationConstants.PIVOT_CW)
{
ser = new PivotCWSerializer();
}
else if (type == OperationConstants.PIVOT_CCW)
{
ser = new PivotCCWSerializer();
}
else if (type == OperationConstants.PER_PART)
{
ser = new CalculatePerPartSerializer();
}
else if (type == OperationConstants.CHANGE_VALUE_ORDER)
{
ser = new ChangeValueOrderSerializer();
}
else if (type == OperationConstants.DELETE_VALUE)
{
ser = new DeleteValueSerializer();
}
else if (type == OperationConstants.DELETE_VARIABLE)
{
ser = new DeleteVariableSerializer();
}
else if (type == OperationConstants.SORT_TIME)
{
ser = new SortTimeVariableSerializer();
}
else if (type == OperationConstants.SPLIT_TIME)
{
ser = new SplitTimevariableSerializer();
}
else if (type == OperationConstants.SUM)
{
ser = new SumSerializer();
}
else if (type == OperationConstants.CHANGE_DECIMALS)
{
ser = new ChangeDecimalsSerializer();
}
else if (type == OperationConstants.CHANGE_TEXT)
{
ser = new ChangeTextSerializer();
}
else if (type == OperationConstants.PIVOT_TIME_TO_HEADING)
{
ser = new PivotTimeToHeadingSerializer();
}
else if (type == OperationConstants.CHANGE_TEXT_CODE_PRESENTATION)
{
ser = new ChangeTextCodePresentationSerializer();
}
return ser;
}
public WorkStep[] GetSteps()
{
return _steps.ToArray();
}
}
}