forked from Vaccano/TFS-Aggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperationEnum.cs
48 lines (42 loc) · 1.16 KB
/
OperationEnum.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
44
45
46
47
48
using System;
namespace TFSAggregator
{
public static class Operations
{
public static double Perform(this OperationEnum operation, double aggregateValue, double sourceValue)
{
if (operation == OperationEnum.Sum)
return aggregateValue + sourceValue;
if (operation == OperationEnum.Subtract)
return aggregateValue - sourceValue;
if (operation == OperationEnum.Multiply)
{
if (aggregateValue ==0.0)
{
aggregateValue = +1;
}
return (aggregateValue*sourceValue);
}
if (operation == OperationEnum.Divide)
{
if (aggregateValue == 0.0)
{
aggregateValue = +1;
return (sourceValue / aggregateValue);
}
else
{
return (aggregateValue / sourceValue);
}
}
throw new InvalidOperationException("Unsupported Aggregation Operation");
}
}
public enum OperationEnum
{
Sum,
Subtract,
Multiply,
Divide
}
}