Universe.Framework.Services.ClassHelpers.Inventory.InventoryFolderImpl.FindFolderByPath C# (CSharp) Méthode

FindFolderByPath() public méthode

Find a folder given a PATH_DELIMITER delimited path starting from this folder
public FindFolderByPath ( string path ) : InventoryFolderImpl
path string /// The path to the required folder. /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. ///
Résultat InventoryFolderImpl
        public InventoryFolderImpl FindFolderByPath (string path)
        {
            if (path == string.Empty)
                return this;

            path = path.Trim ();

            if (path == PATH_DELIMITER)
                return this;

            string [] components = path.Split (new [] { PATH_DELIMITER }, 2, StringSplitOptions.None);

            lock (m_childFolders) {
                foreach (
                    InventoryFolderImpl folder in m_childFolders.Values.Where (folder => folder.Name == components [0])) {
                    if (components.Length > 1)
                        return folder.FindFolderByPath (components [1]);
                    return folder;
                }
            }

            // We didn't find a folder with the given name
            return null;
        }