public override IMediaFolder Transform(IMediaFolder Root) { var root = new VirtualClonedFolder(Root); var titles = new TitlesFolder(root); SortFolder(root, titles); foreach (var i in root.ChildFolders.ToList()) { root.ReleaseFolder(i); } foreach (var i in titles.ChildFolders.ToList()) { root.AdoptFolder(i); } return(root); }
private static void SortFolder(VirtualFolder folder, TitlesFolder titles) { folder.AllItems.GroupBy( r => (r is IMetaInfo) ? ((r as IMetaInfo).InfoDate.ToString("yyyy-MMM")) : "Unknown", r => r, (k, g) => new { Key = k, Lst = g.ToList() } ) .ToList() .ForEach(i => { var tf = titles.GetFolder(i.Key); i.Lst.ForEach(r => { tf.AddResource(r); folder.RemoveResource(r); }); }); }
private static void SortFolder(VirtualFolder folder, TitlesFolder titles) { foreach (var f in folder.ChildFolders.ToList()) { SortFolder(f as VirtualFolder, titles); } foreach (var c in folder.ChildItems.ToList()) { var pre = c.Title.StemCompareBase(); if (string.IsNullOrEmpty(pre)) { pre = "Unnamed"; } pre = pre.First().ToString().ToUpperInvariant(); titles.GetFolder(pre).AddResource(c); folder.RemoveResource(c); } }