Beispiel #1
0
        static DirFilters makeDefaultDirFilters()
        {
            var ret = new DirFilters();

            ret.Add(".git");
            ret.Add(".vs");
            return(ret);
        }
Beispiel #2
0
        void ReadFilters(out DirFilters dirFilters, out FileFilters fileFilters)
        {
            dirFilters  = makeDefaultDirFilters();
            fileFilters = makeDefaultFileFilters();
            try
            {
                var fname = Path.Combine(_rootPath, FiltersFilename);
                if (!File.Exists(fname))
                {
                    return;
                }

                var text = File.ReadAllText(fname);
                using (var json = JsonDocument.Parse(text))
                {
                    var         root = json.RootElement;
                    JsonElement dirs;
                    if (root.TryGetProperty("dirs", out dirs))
                    {
                        var edirs = dirs.EnumerateArray();
                        dirFilters = new DirFilters();
                        foreach (var d in edirs)
                        {
                            dirFilters.Add(d.GetString());
                        }
                    }
                    JsonElement files;
                    if (root.TryGetProperty("files", out files))
                    {
                        var efiles = files.EnumerateArray();
                        fileFilters = new FileFilters();
                        foreach (var f in efiles)
                        {
                            fileFilters.Add(makeFileFilter(f.GetString()));
                        }
                    }
                }
            }
            catch
            {
            }
        }