コード例 #1
0
        public Dictionary<int, IVirtualFile> BuildVirtualFiles(IVirtualDirectory root, string name, int[] subRoots)
        {
            var subrootDir = root.GetDirectory(name);
            subRoots = getCounts(subrootDir, subRoots);

            XmlSerializer ser = new XmlSerializer(typeof(Group));
            var dict = new Dictionary<int, IVirtualFile>();
            foreach (var subroot in subRoots)
            {
                var fs = subrootDir.GetFile(subroot + ".xml").Open();
                if (fs == null) continue;

                var group = ser.Deserialize(fs) as Group;
                if (group == null) continue;

                foreach (var item in group.Source.Items)
                {
                    dict.Add(item.ID, item);
                }
            }
            return dict;
        }
コード例 #2
0
        public Dictionary<int, IVirtualFile> BuildVirtualFiles(IVirtualDirectory root, string name, int[] subRoots)
        {
            // read directory by name
            // dir == artist
            var dir = root.GetDirectory(name);
            Dictionary<int, IVirtualFile> result = new Dictionary<int, IVirtualFile>();
            // get alben
            // iteriere erst über die dirs
            // wähle die deren position in subroots enthalten ist
            int pos = -1;
            int arrayPos = 0;

            foreach (var subdir in dir.GetDirectories())
            {
                pos++;
                if (subRoots != null)
                {
                    if (arrayPos < subRoots.Length)
                    {
                        if (pos == subRoots[arrayPos])
                        {
                            arrayPos++;
                        }
                        else
                            continue;
                    }
                    else
                        continue;

                }
                foreach (var virtualFile in subdir.GetFiles("*.mp3", SearchOption.AllDirectories, c => (pos + 1) * 1000 + c))
                {
                    result.Add(virtualFile.ID, virtualFile);
                }
            }

            return result;
        }