public static AppMetric JoinQueryMetric(AppMetricId metricId, params IAppMetricsProvider[] collections) { if (metricId == null) { throw new ArgumentNullException(nameof(metricId)); } if (collections == null || collections.Length == 0) { throw new ArgumentNullException(nameof(collections)); } AppMetric retVal = null; foreach (IAppMetricsProvider c in collections) { AppMetric cMetric = c.QueryMetric(metricId); if (cMetric != null) { if (retVal != null) { retVal = retVal.JoinWith(cMetric); } else { retVal = cMetric.Copy(); } } } return(retVal); }
public AppMetric QueryMetric(AppMetricId metricId) { if (mMetrics.TryGetValue(metricId, out AppMetric targetMetric)) { return(targetMetric.Copy()); } else { return(null); } }
public long UpdateMetric(AppMetricId metricId, Func <AppMetric, long> updateFn) { if (metricId == null) { throw new ArgumentNullException(nameof(metricId)); } if (updateFn == null) { throw new ArgumentNullException(nameof(updateFn)); } if (mMetrics.TryGetValue(metricId, out AppMetric targetMetric)) { return(updateFn.Invoke(targetMetric)); } else { throw new InvalidOperationException($"Attempted to update unsupported metric: {metricId}"); } }
public AppMetric(AppMetricId id, long value) { mId = id ?? throw new ArgumentNullException(nameof(id)); mValue = value; }
public AppMetric(AppMetricId id) : this(id, 0) { return; }