public Dictionary <string, string> Resolve( object source, MetricData destination, Dictionary <string, string> destMember, ResolutionContext context) { destMember = new Dictionary <string, string>(); Type sourceType = source.GetType(); var accessors = GetUpdateCacheItem(sourceType); if (accessors?.Any() != true) { throw new MissingAttributeException(nameof(IsMetricTag)); } foreach (var item in accessors) { var tagValue = item.Property.GetValue(source)?.ToString() ?? string.Empty; if (tagValue.Trim().Contains(" ")) { tagValue = ValidatorHelper.ToTitleCase(tagValue); } tagValue = ValidatorHelper.TagAndMetricNameValidator(tagValue); if (string.IsNullOrEmpty(tagValue)) { continue; } destMember.Add(item.CustomAttribute.Name, tagValue); } return(destMember); }
private static string GetMetricName(IEnumerable <object> orderedMetric) { var metricName = new StringBuilder(); foreach (var oMetric in orderedMetric) { metricName.Append($"{oMetric}."); } metricName.Length--; var metric = metricName.ToString(); if (metric.Trim().Contains(" ")) { metric = ValidatorHelper.ToTitleCase(metric); } return(ValidatorHelper.TagAndMetricNameValidator(metric)); }