Beispiel #1
0
        public StatsSummaryHolder GetDataXml(StatsSummaryHolder stats, IEnumerable <XElement> itemsList)
        {
            foreach (XElement item in itemsList)
            {
                var itemFieldList = from itemAttr in item.Elements() select itemAttr;

                //Console.WriteLine("* item.name " + item.Name);

                foreach (XElement itemField in itemFieldList)
                {
                    //Console.WriteLine("* itemField.Name " + itemField.Name + " value " + itemField.Value);

                    string key      = ExtractKey(itemField.Name + " " + itemField.Attribute("channel"));
                    string rawValue = itemField.Value;
                    if (key != null && rawValue != null && rawValue != "")
                    {
                        //Console.WriteLine("Key found is " + key);
                        //Console.WriteLine("rawValue " + rawValue);

                        // get value
                        float floatValue = ExtractFloatValue(rawValue);
                        //Console.WriteLine("floatValue is " + floatValue);
                        AddToSummary(stats, key, floatValue);
                    }
                }
            }

            return(stats);
        }
Beispiel #2
0
        public string GetAverageFromSummary(StatsSummaryHolder holder, string key)
        {
            var stats = holder._stats;

            List <float> results;

            results = stats[key];

            var result = results.Average();

            result = (float)Math.Round(result, 2);

            return(DoFormat(result));
        }
Beispiel #3
0
        private void AddToSummary(StatsSummaryHolder holder, string key, float value)
        {
            var stats = holder._stats;

            List <float> sValue = new List <float>();
            bool         exists = stats.TryGetValue(key, out sValue);

            if (exists && !sValue.Contains(value))
            {
                sValue.Add(value);
                stats[key] = sValue;
            }
            else if (!exists)
            {
                sValue = sValue ?? new List <float>();
                sValue.Add(value);
                stats.Add(key, sValue);
            }
        }