Universe.Framework.Services.ClassHelpers.Inventory.InventoryFolderImpl.FindItemByPath C# (CSharp) Method

FindItemByPath() public method

Find an item given a PATH_DELIMITOR delimited path starting from this folder. This method does not handle paths that contain multiple delimiters FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some XPath like expression FIXME: Delimiters which occur in names themselves are not currently escapable.
public FindItemByPath ( string path ) : InventoryItemBase
path string /// The path to the required item. ///
return InventoryItemBase
        public InventoryItemBase FindItemByPath (string path)
        {
            string [] components = path.Split (new [] { PATH_DELIMITER }, 2, StringSplitOptions.None);

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

            // We didn't find an item or intermediate folder with the given name
            return null;
        }