Ejemplo n.º 1
0
        /// <summary>
        /// get the value from the counter and path.
        /// path should be a string splited by dot, like BugQuality.TableQuality.TableBugFixRate
        /// return null if such path doesn't exist
        /// </summary>
        /// <param name="record"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static CounterRecord.ComplexValue Get(CounterRecord record, string path)
        {
            if (record == null || record.Value == null || string.IsNullOrEmpty(path))
            {
                return(null);
            }

            string[] names = path.Split('.');
            CounterRecord.ComplexValue cur = record.Value;
            foreach (string name in names)
            {
                if (cur.RelatedValues == null || cur.RelatedValues.Count == 0)
                {
                    return(null);
                }

                foreach (var value in cur.RelatedValues)
                {
                    if (value != null && name.Equals(value.Name))
                    {
                        cur = value;
                        break;
                    }
                }
                if (cur.Name != name)
                {
                    return(null);
                }
            }

            return(cur == null ? null : cur);
        }
Ejemplo n.º 2
0
 public static object GetValue(CounterRecord record, string path)
 {
     CounterRecord.ComplexValue cur = CounterRecordHelper.Get(record, path);
     return(cur == null ? null : cur.Value);
 }