ContentWithPathComponent() protected method

protected ContentWithPathComponent ( Path component ) : Runtime.Object
component Path
return Runtime.Object
Example #1
0
        public SearchResult ContentAtPath(Path path, int partialPathStart = 0, int partialPathLength = -1)
        {
            if (partialPathLength == -1)
            {
                partialPathLength = path.length;
            }

            var result = new SearchResult();

            result.approximate = false;

            Container currentContainer = this;

            Runtime.Object currentObj = this;

            for (int i = partialPathStart; i < partialPathLength; ++i)
            {
                var comp = path.GetComponent(i);

                // Path component was wrong type
                if (currentContainer == null)
                {
                    result.approximate = true;
                    break;
                }

                var foundObj = currentContainer.ContentWithPathComponent(comp);

                // Couldn't resolve entire path?
                if (foundObj == null)
                {
                    result.approximate = true;
                    break;
                }

                currentObj       = foundObj;
                currentContainer = foundObj as Container;
            }

            result.obj = currentObj;

            return(result);
        }
Example #2
0
        public Runtime.Object ContentAtPath(Path path, int partialPathLength = -1)
        {
            if (partialPathLength == -1)
            {
                partialPathLength = path.length;
            }

            Container currentContainer = this;

            Runtime.Object currentObj = this;

            for (int i = 0; i < partialPathLength; ++i)
            {
                var comp = path.GetComponent(i);
                if (currentContainer == null)
                {
                    throw new System.Exception("Path continued, but previous object wasn't a container: " + currentObj);
                }
                currentObj       = currentContainer.ContentWithPathComponent(comp);
                currentContainer = currentObj as Container;
            }

            return(currentObj);
        }