blob: 0ff67c7486d45f1b4d0c7976402f87915fa821ea (
plain)
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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Tango.DispenserAnalyzer.UI.Analysis
{
public class AnalyzerResultBase : IAnalyzerResult
{
public AnalyzerResultValue Result { get; set; }
public List<AnalysisPlotValue> PlotValues { get; set; }
public List<AnalyzerResultProperty> Properties
{
get
{
List<AnalyzerResultProperty> props = new List<AnalyzerResultProperty>();
if (this.GetType() == typeof(AnalyzerResultBase))
return props;
foreach (var prop in this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly))
{
AnalyzerResultProperty aProp = new AnalyzerResultProperty();
if (prop.GetCustomAttribute<DescriptionAttribute>() != null)
{
aProp.Name = prop.GetCustomAttribute<DescriptionAttribute>().Description;
}
else
{
aProp.Name = prop.Name;
}
object val = prop.GetValue(this);
aProp.Value = (val is double) ? ((double)val).ToString("F") : val.ToString();
props.Add(aProp);
}
return props;
}
}
public AnalyzerResultBase()
{
PlotValues = new List<AnalysisPlotValue>();
Result = AnalyzerResultValue.Undetermined;
}
}
}
|