Ejemplo n.º 1
0
        public IList <KeyValuePair <string, PathType> > Compile(TokenzierContext context, int index)
        {
            if (CurrentPart == ".")
            {
                PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.SelfAssignment));
            }
            else if (CurrentPart == "../")
            {
                PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.ParentSelector));
            }
            else if (CurrentPart == "~")
            {
                PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.RootSelector));
            }
            else if (CurrentPart == "?")
            {
                PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.ObjectSelector));
            }
            else if (CurrentPart.Trim() != "")
            {
                if (CurrentPartIsNumber)
                {
                    PathParts.Add(new KeyValuePair <string, PathType>(CurrentPart, PathType.Number));
                }
                else
                {
                    if (!ComputeCurrentPart(context, index))
                    {
                        return(new KeyValuePair <string, PathType> [0]);
                    }
                }
            }

            if (PathParts.Count > 1 && PathParts.Last().Value == PathType.SelfAssignment)
            {
                PathParts.Remove(PathParts.Last());
            }

            //if (!PathParts.Any())
            //{
            //	hasError = 0;
            //	return PathParts;
            //}

            CurrentPart = "";
            return(PathParts);
        }