Exemplo n.º 1
0
        private void PartitionChildren(VirtualFolder folder, Prefixer prefixer, int startfrom = 1)
        {
            for (var wordcount = startfrom;;)
            {
                var curwc  = wordcount;
                var groups = from i in folder.ChildItems.ToList()
                             let prefix = prefixer.GetWordPrefix(GetTitle(i), curwc)
                                          where !string.IsNullOrWhiteSpace(prefix)
                                          group i by prefix.ToLowerInvariant()
                                          into g
                                          let gcount = g.LongCount()
                                                           where gcount > 3
                                                       orderby g.LongCount() descending
                                                       select g;

                var longest = groups.FirstOrDefault();
                if (longest == null)
                {
                    if (wordcount++ > 5)
                    {
                        return;
                    }
                    continue;
                }

                var newfolder = new VirtualFolder(folder, longest.Key);
                foreach (var item in longest)
                {
                    folder.RemoveResource(item);
                    newfolder.AddResource(item);
                }

                if (newfolder.ChildCount > 100)
                {
                    PartitionChildren(newfolder, prefixer, wordcount + 1);
                }
                if (newfolder.ChildFolders.LongCount() == 1)
                {
                    foreach (var f in newfolder.ChildFolders.ToList())
                    {
                        folder.AdoptFolder(f);
                    }
                }
                else
                {
                    folder.AdoptFolder(newfolder);
                }
            }
        }
 private void CloneFolder(VirtualFolder parent, IMediaFolder folder)
 {
     foreach (var f in folder.ChildFolders) {
     var vf = new VirtualFolder(parent, f.Title, f.Id);
     parent.AdoptFolder(vf);
     CloneFolder(vf, f);
       }
       foreach (var i in folder.ChildItems) {
     if ((types & i.MediaType) == i.MediaType) {
       parent.AddResource(i);
     }
       }
 }
Exemplo n.º 3
0
 private void PartitionChildren(VirtualFolder folder, Prefixer prefixer, int startfrom = 1)
 {
   for (var wordcount = startfrom; ; ) {
     var groups = from i in folder.ChildItems.ToList()
                  let prefix = prefixer.GetWordPrefix(GetTitle(i), wordcount)
                  where !string.IsNullOrWhiteSpace(prefix)
                  group i by prefix
                    into g
                    let gcount = g.LongCount()
                    where gcount > 3
                    orderby g.LongCount() descending
                    select g;
     var longest = groups.FirstOrDefault();
     if (longest == null) {
       if (wordcount++ > 5) {
         return;
       }
       continue;
     }
     var newfolder = new VirtualFolder(folder, longest.Key);
     foreach (var item in longest) {
       folder.RemoveResource(item);
       newfolder.AddResource(item);
     }
     if (newfolder.ChildCount > 100) {
       PartitionChildren(newfolder, prefixer, wordcount + 1);
     }
     if (newfolder.ChildFolders.LongCount() == 1) {
       foreach (var f in newfolder.ChildFolders.ToList()) {
         folder.AdoptFolder(f);
       }
     }
     else {
       folder.AdoptFolder(newfolder);
     }
   }
 }
Exemplo n.º 4
0
 private void CloneFolder(VirtualFolder parent, IMediaFolder folder)
 {
     foreach (var f in folder.ChildFolders)
     {
         var vf = new VirtualFolder(parent, f.Title, f.Id);
         parent.AdoptFolder(vf);
         CloneFolder(vf, f);
     }
     foreach (var i in folder.ChildItems)
     {
         if ((types & i.MediaType) == i.MediaType)
         {
             parent.AddResource(i);
         }
     }
 }
Exemplo n.º 5
0
        public override IMediaFolder Transform(IMediaFolder Root)
        {
            var root       = new VirtualClonedFolder(Root);
            var artists    = new TripleKeyedVirtualFolder(root, "Artists");
            var performers = new TripleKeyedVirtualFolder(root, "Performers");
            var albums     = new DoubleKeyedVirtualFolder(root, "Albums");
            var genres     = new SimpleKeyedVirtualFolder(root, "Genre");
            var folders    = new VirtualFolder(root, "Folders");

            SortFolder(root, artists, performers, albums, genres);
            foreach (var f in root.ChildFolders.ToList())
            {
                folders.AdoptFolder(f);
            }
            root.AdoptFolder(artists);
            root.AdoptFolder(performers);
            root.AdoptFolder(albums);
            root.AdoptFolder(genres);
            root.AdoptFolder(folders);
            return(root);
        }