IProfile IProfile.this[string childpath]
        {
            get
            {
                if (childpath.Length == 0)
                    return this;

                IProfile resolver = this;

                if (childpath.StartsWith("//"))
                {
                    childpath = childpath.Substring(2);
                    resolver = new VirtualNode(_rootnode);
                }
                else if (childpath[0] == '/')
                {
                    childpath = childpath.Substring(1);
                    resolver = new VirtualNode(_rootnode);
                }
                else
                {
                    string currentterm;
                    int firstslash = childpath.IndexOf('/');
                    if (firstslash == -1)
                    {
                        currentterm = childpath;
                        childpath = string.Empty;
                    }
                    else
                    {
                        currentterm = childpath.Substring(0, firstslash);
                        childpath = childpath.Substring(firstslash + 1);
                    }

                    if (currentterm == "..")
                    {
                        if (_node.Path != _rootnode.Path)
                            resolver = new VirtualNode(_rootnode, _node.Parent);
                    }
                    else if (currentterm == ".")
                    {
                    }
                    else
                    {
                        IProfile childnode = _node[currentterm];
                        if (childnode == null)
                            return null;
                        resolver = new VirtualNode(_rootnode, childnode);
                    }
                }

                if (childpath.Length == 0)
                    return resolver;

                return resolver[childpath];
            }
        }
Exemplo n.º 2
0
        IProfile IProfile.this[string childpath]
        {
            get
            {
                if (childpath.Length == 0)
                {
                    return(this);
                }

                IProfile resolver = this;

                if (childpath.StartsWith("//"))
                {
                    childpath = childpath.Substring(2);
                    resolver  = new VirtualNode(_rootnode);
                }
                else if (childpath[0] == '/')
                {
                    childpath = childpath.Substring(1);
                    resolver  = new VirtualNode(_rootnode);
                }
                else
                {
                    string currentterm;
                    int    firstslash = childpath.IndexOf('/');
                    if (firstslash == -1)
                    {
                        currentterm = childpath;
                        childpath   = string.Empty;
                    }
                    else
                    {
                        currentterm = childpath.Substring(0, firstslash);
                        childpath   = childpath.Substring(firstslash + 1);
                    }

                    if (currentterm == "..")
                    {
                        if (_node.Path != _rootnode.Path)
                        {
                            resolver = new VirtualNode(_rootnode, _node.Parent);
                        }
                    }
                    else if (currentterm == ".")
                    {
                    }
                    else
                    {
                        IProfile childnode = _node[currentterm];
                        if (childnode == null)
                        {
                            return(null);
                        }
                        resolver = new VirtualNode(_rootnode, childnode);
                    }
                }

                if (childpath.Length == 0)
                {
                    return(resolver);
                }

                return(resolver[childpath]);
            }
        }