Ejemplo n.º 1
0
        public static IEnumerable <string> EnumerateCategories(this OGLContext context, string type)
        {
            HashSet <string> result = new HashSet <string>();

            foreach (var f in SourceManager.GetAllDirectories(context, type))
            {
                Uri source = new Uri(f.Key.FullName);
                //context.ImportStandaloneFeatures();
                var cats = f.Key.EnumerateDirectories("*", SearchOption.AllDirectories);
                foreach (DirectoryInfo d in cats)
                {
                    result.Add(SourceManager.Cleanname(Uri.UnescapeDataString(source.MakeRelativeUri(new Uri(d.FullName)).ToString()), type));
                }
            }
            return(from s in result orderby s select s);
        }
        public static IEnumerable <string> EnumerateCategories(this OGLContext context, string type)
        {
            HashSet <string> result = new HashSet <string>();

            foreach (var f in SourceManager.GetAllDirectories(context, type))
            {
                Uri source = new Uri(f.Key.FullName);
                //context.ImportStandaloneFeatures();
                var cats = f.Key.EnumerateDirectories("*", SearchOption.AllDirectories);
                foreach (DirectoryInfo d in cats)
                {
                    result.Add(SourceManager.Cleanname(Uri.UnescapeDataString(source.MakeRelativeUri(new Uri(d.FullName)).ToString()), type));
                }
            }
            string t  = type.TrimEnd('/', '\\').ToLowerInvariant() + "/";
            string tt = type.TrimEnd('/', '\\').ToLowerInvariant() + "\\";

            foreach (var z in SourceManager.GetAllZips(context, type))
            {
                foreach (ZipArchiveEntry a in z.Key.Entries)
                {
                    string f  = z.Value.ToLowerInvariant() + "/" + t;
                    string ff = z.Value.ToLowerInvariant() + "\\" + tt;
                    if (a.Length == 0)
                    {
                        string name = a.FullName.ToLowerInvariant();
                        if (a.FullName.StartsWith(t))
                        {
                            result.Add(a.FullName.Substring(t.Length).TrimEnd('/', '\\'));
                        }
                        else if (a.FullName.StartsWith(f))
                        {
                            result.Add(a.FullName.Substring(f.Length).TrimEnd('/', '\\'));
                        }
                        else if (a.FullName.StartsWith(tt))
                        {
                            result.Add(a.FullName.Substring(tt.Length).TrimEnd('/', '\\'));
                        }
                        else if (a.FullName.StartsWith(ff))
                        {
                            result.Add(a.FullName.Substring(ff.Length).TrimEnd('/', '\\'));
                        }
                    }
                }
            }
            return(result.OrderBy(s => s).Distinct());
        }