Beispiel #1
0
        public Component Find(string FullPath)
        {
            // ------------------------------------------------------
            // Locates a component with the specified full path
            // e.g. /RootComponent/Child/SubChild
            // ------------------------------------------------------

            if (FullPath == "")
            {
                throw new Exception("Cannot call Find with a blank path");
            }
            if (FullPath[0] != Component.Delimiter)
            {
                throw new Exception("Path must be fully qualified: " + FullPath);
            }

            int    Pos = FullPath.IndexOf(Component.Delimiter, 1);
            string RootName, NamePath;

            if (Pos == -1)
            {
                RootName = FullPath.Substring(1);
                NamePath = "";
            }
            else
            {
                RootName = FullPath.Substring(1, Pos - 1);
                NamePath = FullPath.Substring(Pos + 1);
            }
            if (RootName.ToLower() != RootComponent.Name.ToLower())
            {
                return(null);
            }
            if (NamePath == "")
            {
                return(RootComponent);
            }
            else
            {
                return(RootComponent.Find(NamePath));
            }
        }