private IElement CreatePhraseElement(IElementFactory elementFactory, IElement parent)
 {
     if (_subsetMatching)
     {
         return(elementFactory.CreateSubset(parent, _phrase, _matchMode));
     }
     if (elementFactory is SrgsElementCompilerFactory)
     {
         XmlParser.ParseText(parent, _phrase, null, null, -1f, elementFactory.CreateToken);
         return(null);
     }
     return(elementFactory.CreateText(parent, _phrase));
 }
Пример #2
0
 private IElement CreatePhraseElement(IElementFactory elementFactory, IElement parent)
 {
     if (_subsetMatching)
     {
         // Create and return the ISubset representing the current phrase
         return(elementFactory.CreateSubset(parent, _phrase, _matchMode));
     }
     else
     {
         if (elementFactory is SrgsElementCompilerFactory)
         {
             XmlParser.ParseText(parent, _phrase, null, null, -1f, new CreateTokenCallback(elementFactory.CreateToken));
         }
         else
         {
             // Create and return the IElementText representing the current phrase
             return(elementFactory.CreateText(parent, _phrase));
         }
     }
     return(null);
 }
Пример #3
0
        private void ProcessChildNodes(SrgsElement srgsElement, IElement parent, IRule rule)
        {
            Type     type    = srgsElement.GetType();
            IElement element = null;
            IRule    rule2   = parent as IRule;
            IItem    item    = parent as IItem;

            if (type == typeof(SrgsRuleRef))
            {
                element = ParseRuleRef((SrgsRuleRef)srgsElement, parent);
            }
            else if (type == typeof(SrgsOneOf))
            {
                element = ParseOneOf((SrgsOneOf)srgsElement, parent, rule);
            }
            else if (type == typeof(SrgsItem))
            {
                element = ParseItem((SrgsItem)srgsElement, parent, rule);
            }
            else if (type == typeof(SrgsToken))
            {
                element = ParseToken((SrgsToken)srgsElement, parent);
            }
            else if (type == typeof(SrgsNameValueTag))
            {
                element = ParseNameValueTag((SrgsNameValueTag)srgsElement, parent);
            }
            else if (type == typeof(SrgsSemanticInterpretationTag))
            {
                element = ParseSemanticTag((SrgsSemanticInterpretationTag)srgsElement, parent);
            }
            else if (type == typeof(SrgsSubset))
            {
                element = ParseSubset((SrgsSubset)srgsElement, parent);
            }
            else if (type == typeof(SrgsText))
            {
                SrgsText     srgsText = (SrgsText)srgsElement;
                string       text     = srgsText.Text;
                IElementText value    = _parser.CreateText(parent, text);
                ParseText(parent, text, null, null, -1f);
                if (rule2 != null)
                {
                    _parser.AddElement(rule2, value);
                }
                else if (item != null)
                {
                    _parser.AddElement(item, value);
                }
                else
                {
                    XmlParser.ThrowSrgsException(SRID.InvalidElement);
                }
            }
            else
            {
                XmlParser.ThrowSrgsException(SRID.InvalidElement);
            }
            IOneOf oneOf = parent as IOneOf;

            if (oneOf != null)
            {
                IItem item2 = element as IItem;
                if (item2 != null)
                {
                    _parser.AddItem(oneOf, item2);
                }
                else
                {
                    XmlParser.ThrowSrgsException(SRID.InvalidElement);
                }
            }
            else if (rule2 != null)
            {
                _parser.AddElement(rule2, element);
            }
            else if (item != null)
            {
                _parser.AddElement(item, element);
            }
            else
            {
                XmlParser.ThrowSrgsException(SRID.InvalidElement);
            }
        }