public virtual bool Configure(Dictionary<string, object> config) { CounterCategory = Helper.DictionaryValue(config, "Category"); CounterName = Helper.DictionaryValue(config, "Name"); CounterInstance = Helper.DictionaryValue(config, "Instance"); CollectdPlugin = Helper.DictionaryValue(config, "CollectdPlugin"); CollectdPluginInstance = Helper.DictionaryValue(config, "CollectdPluginInstance"); CollectdType = Helper.DictionaryValue(config, "CollectdType"); CollectdTypeInstance = Helper.DictionaryValue(config, "CollectdTypeInstance"); string transformer = Helper.DictionaryValue(config, "Transformer"); if (transformer != null) { MethodInfo transformMethodInfo = typeof(Helper).GetMethod("_ConvertFrom" + transformer); if (transformMethodInfo != null) { _transform = (Helper.TransformFunction)Delegate.CreateDelegate(typeof(Helper.TransformFunction), transformMethodInfo); } } return true; }
public virtual bool Configure(Dictionary <string, object> config) { CounterCategory = Helper.DictionaryValue(config, "Category"); CounterName = Helper.DictionaryValue(config, "Name"); CounterInstance = Helper.DictionaryValue(config, "Instance"); CollectdPlugin = Helper.DictionaryValue(config, "CollectdPlugin"); CollectdPluginInstance = Helper.DictionaryValue(config, "CollectdPluginInstance"); CollectdType = Helper.DictionaryValue(config, "CollectdType"); CollectdTypeInstance = Helper.DictionaryValue(config, "CollectdTypeInstance"); string transformer = Helper.DictionaryValue(config, "Transformer"); if (transformer != null) { MethodInfo transformMethodInfo = typeof(Helper).GetMethod("_ConvertFrom" + transformer); if (transformMethodInfo != null) { _transform = (Helper.TransformFunction)Delegate.CreateDelegate(typeof(Helper.TransformFunction), transformMethodInfo); } } return(true); }
public List <double> Retrive(Helper.TransformFunction transform) { var vals = new List <double>(); foreach (PerformanceCounter counter in Counters) { double val; try { val = counter.NextValue(); if (transform != null) { val = transform.Invoke(val); } } catch (InvalidOperationException) { return(null); } vals.Add(val); } return(vals); }