public bool Register(EnumCacheType cacheType, ResetDelegate resetDelegate) { var iType = (int)cacheType; if (!_cacheDic.ContainsKey(iType)) { _cacheDic.Add(iType, resetDelegate); LogHelper.Insert(cacheType.ToString() + " register success.", LogType.Info); return(true); } return(true); }
public static CacheOfSamplingData CreateCacheData <T>(T Data, EnumCacheType type) { CacheOfSamplingData backData = new CacheOfSamplingData(); backData.CacheType = type; switch (type) { case EnumCacheType.CharacterValue: backData.Mac = (Data as tEigenValueParam).mac.ToHexString(); backData.SamplingTime = GetSamplingTime((Data as tEigenValueParam).SampleTime); break; case EnumCacheType.TmpVoltage: backData.Mac = (Data as tTmpVoltageParam).mac.ToHexString(); backData.SamplingTime = GetSamplingTime((Data as tTmpVoltageParam).SampleTime); break; case EnumCacheType.CriticalValue: backData.Mac = (Data as tRevStopParam).mac.ToHexString(); backData.SamplingTime = GetSamplingTime((Data as tRevStopParam).SampleTime); break; case EnumCacheType.LQValue: backData.Mac = (Data as tLQParam).mac.ToHexString(); backData.SamplingTime = GetSamplingTime((Data as tLQParam).SampleTime); break; default: backData.Mac = (Data as WSWaveInfo).MAC; backData.SamplingTime = (Data as WSWaveInfo).WaveDescInfo.SamplingTime; break; } return(backData); }