private string HostBaseMacro(XPathStat stat, string xpath)
        {
            if (string.IsNullOrEmpty(stat.RawBaseValueXPath))
            {
                return(xpath);
            }

            return(Regex.Replace(xpath, @"\#base", string.Format("({0})", stat.BaseValueXPath)));
        }
Esempio n. 2
0
 public ConvertedComparer(XPathStat <TStat> owner)
 {
     _owner = owner;
 }
        private void PreprocessStat(XPathStat stat)
        {
            if (Core.Support.EnableXPathStatDebug && _preprocessSet.Contains(stat))
            {
                Core.Support.LogError(this, "circular reference detected in stats xml file");
                return;
            }

            if (_preprocessedSet.Contains(stat))
            {
                return;
            }

            _preprocessSet.Add(stat);

            if (Core.Support.EnableXPathStatDebug)
            {
                Core.Support.LogInfo(this,
                                     string.Format("preprocessing stat '{0}': BaseValueXPath={1}",
                                                   stat.Key,
                                                   stat.BaseValueXPath));
            }

            stat.BaseValueXPath = this.HostStatMacro(stat, stat.BaseValueXPath, s => s.BaseValueXPath);

            if (Core.Support.EnableXPathStatDebug)
            {
                Core.Support.LogInfo(this,
                                     string.Format("{0}.BaseValueXPath expanded to {1}",
                                                   stat.Key,
                                                   stat.BaseValueXPath));
            }

            if (Core.Support.EnableXPathStatDebug)
            {
                Core.Support.LogInfo(this,
                                     string.Format("preprocessing stat '{0}': XPath={1}",
                                                   stat.Key,
                                                   stat.XPath));
            }

            stat.XPath = this.HostBaseMacro(stat, stat.XPath);
            stat.XPath = this.HostStatMacro(stat, stat.XPath, s => s.XPath);

            if (Core.Support.EnableXPathStatDebug)
            {
                Core.Support.LogInfo(this,
                                     string.Format("{0}.XPath expanded to {1}", stat.Key, stat.XPath));
            }

            if (stat.ShowConditionXPath != null)
            {
                if (Core.Support.EnableXPathStatDebug)
                {
                    Core.Support.LogInfo(this,
                                         string.Format(
                                             "preprocessing stat '{0}': ShowConditionXPath={1}",
                                             stat.Key,
                                             stat.ShowConditionXPath));
                }

                stat.ShowConditionXPath = this.HostValueMacro(stat, stat.ShowConditionXPath);
                stat.ShowConditionXPath = this.HostBaseMacro(stat, stat.ShowConditionXPath);
                stat.ShowConditionXPath = this.HostStatMacro(stat, stat.ShowConditionXPath, s => s.XPath);

                if (Core.Support.EnableXPathStatDebug)
                {
                    Core.Support.LogInfo(this,
                                         string.Format("{0}.ShowConditionXPath expanded to {1}",
                                                       stat.Key,
                                                       stat.ShowConditionXPath));
                }
            }

            if (Core.Support.EnableXPathStatDebug)
            {
                Core.Support.LogInfo(this,
                                     string.Format("preprocessing stat '{0}': ComparisonXPath={1}",
                                                   stat.Key,
                                                   stat.ComparisonXPath));
            }

            stat.ComparisonXPath = this.HostValueMacro(stat, stat.ComparisonXPath);
            stat.ComparisonXPath = this.HostBaseMacro(stat, stat.ComparisonXPath);

            if (Core.Support.EnableXPathStatDebug)
            {
                Core.Support.LogInfo(this,
                                     string.Format("{0}.ComparisonXPath expanded to {1}",
                                                   stat.Key,
                                                   stat.ComparisonXPath));
            }

            _preprocessedSet.Add(stat);
            _preprocessSet.Remove(stat);
        }
 private string HostValueMacro(XPathStat stat, string xpath)
 {
     return(Regex.Replace(xpath, @"\#value", string.Format("({0})", stat.XPath)));
 }
 private string HostStatMacro(XPathStat stat, string xpath, Func <XPathStat, string> xpathGetter)
 {
     return(Regex.Replace(xpath, @"\#stat\(\s*(\w+)\s*\)", m => this.ExpandStatMacro(m, xpathGetter)));
 }