Example #1
0
        public void ExtractToScope(ExtractScope Scope)
        {
            string attrName  = GetNotNullAttrValue("name");
            string paramName = GetNotNullAttrValue("paramName");
            string rawReturn = OperateElement.Attr(attrName);

            if (IsOperateNode() == false)
            {
                Scope.Set(paramName, rawReturn);
            }
            else
            {
                string opType = GetNotNullAttrValue("op");
                if (opType.Equals("Regex", StringComparison.InvariantCultureIgnoreCase))
                {
                    string pattern = GetNotNullAttrValue("pattern");
                    string retVal  = GetNotNullAttrValue("retVal");
                    if (string.IsNullOrEmpty(retVal))
                    {
                        int   groupVal = Convert.ToInt32("0" + GetNotNullAttrValue("retGroup"));
                        Match m        = Regex.Match(rawReturn, pattern);
                        if (m.Success && m.Groups.Count > groupVal)
                        {
                            Scope.Set(paramName, m.Groups[groupVal].Value);
                        }
                    }
                    else
                    {
                        Regex RE = new Regex(pattern, RegexOptions.IgnoreCase);
                        Scope.Set(paramName, RE.Replace(rawReturn, retVal));
                    }
                }
            }
        }