示例#1
0
        /// <summary>
        ///		Get successor or predecessor of this folder at the same level of the folders hierarchy
        /// </summary>
        /// <param name="backwards">
        ///		<see langword="true"/> for predecessor
        ///		<see langword="false"/> for successor
        /// </param>
        /// <returns>
        ///		<see langword="null"/> if none exist
        /// </returns>
        public IDataFolder GetNextSiblingInTree(bool backwards)
        {
            Check.RequireLambda(!IsVirtualRoot, () => new InvalidOperationException(StorageResources.VirtualRootInvalidOperation));

            IDataFolder retval = ParentDataFolder.GetNextChild(this, backwards);

            if (null == retval)
            {
                if (!ParentDataFolder.IsVirtualRoot)
                {
                    for (
                        IDataFolder nst = ParentDataFolder.GetNextSiblingInTree(backwards);
                        nst != null && retval == null;
                        nst = nst.GetNextSiblingInTree(backwards))
                    {
                        retval = nst.GetFirstChildFolder(backwards);
                    }
                }
            }
            return(retval);
        }
示例#2
0
        /// <summary>
        ///		Get next data file in the same repo folder.
        /// </summary>
        /// <param name="backwards">
        ///		The direction in which to look for data file relative to this file: to the past or to the future
        /// </param>
        /// <returns>
        ///		Next data file or <see langword="null"/> if none exists.
        /// </returns>
        public IRepositoryFile GetNext(bool backwards)
        {
            IRepositoryFile retval = null;

            IRepositoryFileName fileInSameFolder = ContainingFolder.GetNextDataFile(this.Name, backwards);

            if (null != fileInSameFolder)
            {
                retval = new RepositoryFile(containingFolder: ContainingFolder, fileName: fileInSameFolder);
            }
            else
            {
                // scanning sibling leaf folders until first data file is found
                for (
                    IDataFolder nextFolder = ContainingFolder.GetNextSiblingInTree(backwards);
                    nextFolder != null && retval == null;
                    nextFolder = nextFolder.GetNextSiblingInTree(backwards))
                {
                    retval = nextFolder.FindFirstDataFile(backwards);
                }
            }

            return(retval);
        }