Exemplo n.º 1
0
        public Resource GetResource(String path, Boolean last)
        {
            if (String.IsNullOrEmpty(path))
            {
                return(this);
            }

            // find root for absolute path
            if (path.StartsWith("/"))
            {
                Resource root = this;
                while (root._parent != null)
                {
                    root = root._parent;
                }
                path = path.Equals("/") ? null : path.Substring(1);
                return(root.GetResource(path));
            }

            Int32  pos = path.IndexOf('/');
            String head = null, tail = null;

            // note: "some/resource/" addresses a resource "" under "resource"
            if (pos == -1)
            {
                head = path;
            }
            else
            {
                head = path.Substring(0, pos);
                tail = path.Substring(pos + 1);
            }

            if (SubResources.ContainsKey(head))
            {
                return(SubResources[head].GetResource(tail, last));
            }
            else if (last)
            {
                return(this);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
 public void AddSubResource(string subResource, string value)
 {
     SubResources.Add(subResource, value);
 }