public void ProcessCreateTester() { ProcessFactory.Init(); IAggProcess process = ProcessFactory.GetAggProcess(AggWay.Avg); Assert.IsNotNull(process); process = ProcessFactory.GetAggProcess(AggWay.Min); Assert.IsNotNull(process); process = ProcessFactory.GetAggProcess(AggWay.Max); Assert.IsNotNull(process); }
public void MinProcessTester() { ProcessFactory.Init(); IAggProcess process = ProcessFactory.GetAggProcess(AggWay.Min); AggResult result = process.AggProcess(CreateAggRawData()); Assert.IsNotNull(result); foreach (var aggdata in result.AggDatas) { Assert.IsTrue(aggdata.Values.Count == 3); foreach (var value in aggdata.Values) { Assert.IsTrue(value == Convert.ToDouble(100)); } } }
public static IAggProcess GetAggProcess(AggWay way) { IAggProcess process = null; if (processes.ContainsKey(way)) { processes.TryGetValue(way, out process); } else { process = CreateAggProcess(way); if (process != null) { processes.TryAdd(way, process); } } return(process); }
private static IAggProcess CreateAggProcess(AggWay way) { IAggProcess iProcess = null; if (!processTypes.ContainsKey(way.ToString())) { iProcess = null; return(iProcess); } Type type = processTypes[way.ToString()]; try { iProcess = Activator.CreateInstance(type) as IAggProcess; } catch (Exception e) { Log.ErrorFormat("create aggprocess failed, type:{0},error:{1},stacktrace{2}", way.ToString(), e.Message, e.StackTrace); } return(iProcess); }
public AggTask(IDataPool dataPool, IAggProcess aggProcess) { this.dataPool = dataPool; this.process = aggProcess; }