private static string GetAttributeText(INObject obj, IReadOnlyDictionary <string, DValue> attributes, INAttribute attr) { DValue value; attributes.TryGetValue(attr.Name, out value); var strValue = value?.Value?.ToString(); if (attr.Type == MAttrType.Numerator) { try { return(GetNumeratorAttributeText(obj, strValue, attr.ParsedConfiguration().CounterDescriptions)); } catch (FormatException) { return(string.Empty); } } return(strValue); }
public static string GetNumeratorAttributeText(INObject obj, INAttribute attr, string attrValue) { if (string.IsNullOrEmpty(attrValue)) { return(null); } var description = attr.ParsedConfiguration().CounterDescriptions; var keywordProvider = new INumeratorKeywordProvider <INObject>[] { GetCurrentDateKeywordProviders(attrValue, description), new UnknownProvider(description.DraftText) }; if (attrValue.StartsWith(NumeratorDescription.Deferred)) { attrValue = attrValue.Substring(NumeratorDescription.Deferred.Length); } return(new NumeratorFormatter <INObject>(new NumeratorKeywordProviderAggregator <INObject>(keywordProvider)).Format(obj, attrValue)); }