Пример #1
0
 private static void HandleCurrentPositionInMember(OPathParseResult parseResult, char opathChar)
 {
     if (IsMemberChar(opathChar))
     {
         parseResult.AppendToMember(opathChar);
         parseResult.ResetWhitespace();
     }
     else if (IsOpeningBracket(opathChar))
     {
         parseResult.CurrentPosition = OPathParsePosition.InMethodParameters;
         parseResult.ResetWhitespace();
     }
     else if (IsMemberPrefixChar(opathChar))
     {
         parseResult.CurrentPosition = OPathParsePosition.InMember;
         parseResult.AddOPathPropertyPart();
         parseResult.ResetWhitespace();
     }
     else if (IsIndexerStartChar(opathChar))
     {
         parseResult.CurrentPosition = OPathParsePosition.PreIndexerValue;
         parseResult.AddOPathPropertyPart();
         parseResult.ResetWhitespace();
     }
     else if (IsWhitespaceChar(opathChar))
     {
         parseResult.AppendCharToWhitespace();
     }
     else
     {
         parseResult.CurrentPosition = OPathParsePosition.InExpression;
         parseResult.AddOPathPropertyPart();
         parseResult.AddVariable();
         parseResult.AppendToXPath(parseResult.GetAndResetWhitespace());
         parseResult.AppendToXPath(opathChar);
     }
 }
Пример #2
0
        private static void HandleCurrentPositionInIdentifier(OPathParseResult parseResult, char opathChar,
                                                              int opathCharIndex)
        {
            if (IsIdentifierChar(opathChar))
            {
                if (parseResult.HasWhitespace)
                {
                    string identifier = parseResult.GetIdentifier();

                    if (IsStandardSourceObjectIdentifier(identifier))
                    {
                        parseResult.ResetIdentifier();
                        parseResult.AddVariable(identifier);
                        parseResult.AppendWhitespaceCharToXPath();
                    }
                }

                parseResult.AppendToIdentifier(opathChar);
            }
            else if (IsWhitespaceChar(opathChar))
            {
                string identifier = parseResult.GetIdentifier();

                if (IsXPathOperator(identifier))
                {
                    parseResult.CurrentPosition = OPathParsePosition.InExpression;
                    parseResult.ResetIdentifier();
                    parseResult.AppendOperatorToXPath(identifier);
                    parseResult.AppendWhitespaceCharToXPath();
                }
                else
                {
                    parseResult.AppendCharToWhitespace();
                }
            }
            else if (IsOpeningBracket(opathChar))
            {
                parseResult.CurrentPosition = OPathParsePosition.InExpression;
                string identifier = parseResult.GetAndResetIdentifier();
                parseResult.AppendFunctionToXPath(identifier);
                parseResult.AppendToXPath(opathChar);
                parseResult.ResetWhitespace();
            }
            else if (IsMemberPrefixChar(opathChar))
            {
                parseResult.CurrentPosition     = OPathParsePosition.InMember;
                parseResult.CurrentVariableName = parseResult.GetAndResetIdentifier();
                parseResult.MemberStartIndex    = opathCharIndex;
                parseResult.ResetWhitespace();
            }
            else if (IsIndexerStartChar(opathChar))
            {
                parseResult.CurrentPosition     = OPathParsePosition.PreIndexerValue;
                parseResult.CurrentVariableName = parseResult.GetAndResetIdentifier();
                parseResult.IndexerStartIndex   = opathCharIndex;
                parseResult.ResetWhitespace();
            }
            else if (IsStringDelimiterChar(opathChar))
            {
                parseResult.CurrentPosition        = OPathParsePosition.InString;
                parseResult.CurrentStringDelimiter = opathChar;
                parseResult.AppendToXPath(opathChar);
                parseResult.StringStartIndex = opathCharIndex;
            }
            else
            {
                parseResult.CurrentPosition = OPathParsePosition.InExpression;

                string identifier = parseResult.GetAndResetIdentifier();

                if (IsXPathOperator(identifier))
                {
                    parseResult.AppendOperatorToXPath(identifier);
                }
                else
                {
                    parseResult.AddVariable(identifier);
                }

                parseResult.AppendToXPath(parseResult.GetAndResetWhitespace());
                parseResult.AppendToXPath(opathChar);
            }
        }