Exemplo n.º 1
0
        protected RemoteItem(string path, char pathSeparator, string rootPath = null)
        {
            Path          = path ?? "";
            PathSeparator = pathSeparator;
            RelativePath  = !string.IsNullOrEmpty(rootPath) ? Path.Replace(rootPath, "") : Path;
            PathParts     = RelativePath.Split(PathSeparator);
            RootPath      = rootPath ?? "";

            _ancestors = new Lazy <IReadOnlyCollection <IRemoteFolder> >(() => GetAncestors().ToArray());
            _name      = new Lazy <string>(() => PathParts.Last());
        }
Exemplo n.º 2
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);
        }