MetricTypeInfo GetMetricTypeInfo() { var type = GetType(); MetricTypeInfo info; if (s_typeInfoCache.TryGetValue(type, out info)) { return(info); } lock (s_typeInfoCache) { if (s_typeInfoCache.TryGetValue(type, out info)) { return(info); } var needsPreSerialize = type.GetMethod(nameof(PreSerialize), BindingFlags.Instance | BindingFlags.NonPublic).DeclaringType != typeof(BosunMetric); var isExternalCounter = typeof(ExternalCounter).IsAssignableFrom(type); info = s_typeInfoCache[type] = new MetricTypeInfo { NeedsPreSerialize = needsPreSerialize, IsExternalCounter = isExternalCounter, }; return(info); } }
MetricTypeInfo GetMetricTypeInfo() { var type = GetType(); if (s_typeInfoCache.TryGetValue(type, out var info)) { return(info); } lock (s_typeInfoCache) { if (s_typeInfoCache.TryGetValue(type, out info)) { return(info); } var needsPreSerialize = type.GetMethod(nameof(PreSerialize), BindingFlags.Instance | BindingFlags.NonPublic).DeclaringType != typeof(MetricBase); info = s_typeInfoCache[type] = new MetricTypeInfo { NeedsPreSerialize = needsPreSerialize, }; return(info); } }