internal XElement ExecuteFSM(IEnumerator <XElement> enumerator, XName requestingXName, WildCard requestingWildCard)
        {
            XElement xElement;
            XElement currElem         = null;
            WildCard matchingWildCard = null;
            XName    matchingName     = null;

            while (true)
            {
                if (enumerator.MoveNext())
                {
                    currElem          = enumerator.Current;
                    this.currentState = this.FsmMakeTransition(this.currentState, currElem.Name, out matchingName, out matchingWildCard);
                    if (this.currentState == FSM.InvalidState)
                    {
                        xElement = null;
                        break;
                    }
                    else if (!(requestingXName == null ? true : !(matchingName != null)))
                    {
                        if (requestingXName.Equals(currElem.Name))
                        {
                            xElement = currElem;
                            break;
                        }
                    }
                    else if ((requestingWildCard == null ? false : matchingWildCard != null))
                    {
                        if (requestingWildCard.Allows(currElem.Name))
                        {
                            xElement = currElem;
                            break;
                        }
                    }
                }
                else
                {
                    xElement = null;
                    break;
                }
            }
            return(xElement);
        }
Example #2
0
        internal XElement ExecuteFSM(IEnumerator <XElement> enumerator, XName requestingXName,
                                     WildCard requestingWildCard)
        {
            XElement currElem         = null;
            WildCard matchingWildCard = null;
            XName    matchingName     = null;

            while (enumerator.MoveNext())
            {
                currElem     = enumerator.Current;
                currentState = FsmMakeTransition(currentState, currElem.Name, out matchingName, out matchingWildCard);

                if (currentState != FSM.InvalidState)
                {
                    if ((requestingXName != null) && (matchingName != null))
                    {
                        if (requestingXName.Equals(currElem.Name))
                        {
                            return(currElem);
                        }
                    }
                    else if ((requestingWildCard != null) && (matchingWildCard != null))
                    {
                        //requesting for ANY
                        if (requestingWildCard.Allows(currElem.Name)
                            ) //Make sure current element is allowed by requesting ANY property
                        {
                            return(currElem);
                        }
                    }
                }
                else
                {
                    //Get stuck. No recovery attempt is provided for now.
                    return(null);
                }
            }

            //No matching elements/wildcards are found
            return(null);
        }