Esempio n. 1
0
        private void LoadProfileVars(XmlDocument doc, string xpath, string profileId)
        {
            var root = doc.SelectSingleNode(xpath);

            if (root != null)
            {
                foreach (XmlNode node in root.SelectNodes("item"))
                {
                    ProfileVar pvar = CreateProfileVar(node as XmlElement, profileId);

                    if (!this.ProfileVars.ContainsKey(pvar.Name))
                    {
                        this.ProfileVars.Add(pvar.Name, new List <ProfileVar>());
                    }

                    ProfileVars[pvar.Name].Add(pvar);
                }
            }
        }
Esempio n. 2
0
        private ProfileVar CreateProfileVar(XmlElement xmlElement, string profileId)
        {
            ProfileVar ret = new ProfileVar();

            ret.ProfileId = profileId;
            ret.Name      = xmlElement.GetAttribute("name");

            //parse name and extract source file
            var   rexp = new Regex(@"([^\(@\t]*)\t*(\([^\)]*\))?(@THREAD_\S*)?");
            Match mtch = rexp.Match(ret.Name);

            ret.Name       = mtch.Groups[1].Value;
            ret.SourceFile = mtch.Groups[2].Success ? mtch.Groups[2].Value : null;
            ret.ThreadId   = mtch.Groups[3].Success ? mtch.Groups[3].Value : null;

            ret.StringValue = xmlElement.GetAttribute("value");

            //check subitems
            XmlElement elTotalTime = xmlElement.SelectSingleNode("subitem[@name='TotalTime']") as XmlElement;
            XmlElement elCount     = xmlElement.SelectSingleNode("subitem[@name='Count']") as XmlElement;

            if (elTotalTime != null)
            {
                ret.StringValue = elTotalTime.GetAttribute("value");
            }

            if (elCount != null)
            {
                ret.RunCount = Convert.ToInt32(elCount.GetAttribute("value"));
            }
            else
            {
                ret.RunCount = elTotalTime == null ? 0 : 1;
            }

            if (!Double.TryParse(ret.StringValue, out ret.Value))
            {
                ret.Value = Double.NaN;
            }

            return(ret);
        }