/// <summary> /// /// </summary> /// <param name="status"></param> /// <param name="file"></param> /// <param name="previousWatermark"></param> /// <param name="fromDirectory"> /// See <see cref="SoundboxFileMoveEvent.FromDirectory"/> /// </param> public FileResult(ResultStatus status, SoundboxNode file, Guid?previousWatermark, SoundboxDirectory fromDirectory = null) : base(status) { if (file != null) { File = file.Flatten(true); } PreviousWatermark = previousWatermark; if (fromDirectory != null) { FromDirectory = fromDirectory.Flatten() as SoundboxDirectory; } }
/// <summary> /// Returns the given directory's children (i.e. fetches <see cref="SoundboxDirectory.Children"/>). /// </summary> /// <param name="directory">The directory content to fetch. Null for base directory</param> /// <param name="recursive">Whether to recursively fetch the entire file branch.</param> /// <returns> /// The directory's content. If null is passed for the <paramref name="directory"/> (requesting the root directory) and <paramref name="recursive"/> is false /// then only the root directory is returned without its children. That can be utilized to quickly verify whether the local sound list is up-to-date by checking the root directory's <see cref="SoundboxDirectory.Watermark"/>. /// </returns> public async Task <ICollection <SoundboxNode> > GetSounds(SoundboxDirectory directory = null, bool recursive = false) { SoundboxDirectory serverDirectory = await GetSoundbox().GetDirectory(directory); if (directory == null && recursive) { //return the entire tree return(new SoundboxNode[] { serverDirectory }); } if (directory == null) { //root directory without children return(new SoundboxNode[] { serverDirectory.Flatten() }); } //return the requested directory's children if (serverDirectory == null) { //invalid directory has been passed return(null); } if (recursive) { return(serverDirectory.Children); } //else: flatten the result; do not return the children's children ICollection <SoundboxNode> children = new List <SoundboxNode>(); foreach (var child in serverDirectory.Children) { children.Add(child.Flatten()); } return(children); }