mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add Syntax seed
This commit is contained in:
parent
254af58933
commit
edb4e13771
2 changed files with 44 additions and 1 deletions
|
|
@ -31,13 +31,14 @@ public static void EnsureSeeded(this FilterListsDbContext context)
|
|||
{
|
||||
if (context.FilterLists.Any()) return;
|
||||
Seed<License>(context);
|
||||
Seed<Syntax>(context);
|
||||
Seed<FilterList>(context);
|
||||
}
|
||||
|
||||
private static void Seed<T>(DbContext context)
|
||||
{
|
||||
var rows = JsonConvert.DeserializeObject<List<T>>(
|
||||
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(T) + ".json"));
|
||||
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(T).Name + ".json"));
|
||||
context.AddRange(rows);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
|
|
|||
42
src/FilterLists.Api/Seed/Syntax.json
Normal file
42
src/FilterLists.Api/Seed/Syntax.json
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
[
|
||||
{
|
||||
"Id": 1,
|
||||
"DefinitionUrl": "https://en.wikipedia.org/wiki/Hosts_(file)",
|
||||
"Name": "Hosts"
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"DefinitionUrl": null,
|
||||
"Name": "Domains"
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"DefinitionUrl": "https://adblockplus.org/filters",
|
||||
"Name": "Adblock Plus"
|
||||
},
|
||||
{
|
||||
"Id": 4,
|
||||
"DefinitionUrl": "https://github.com/gorhill/uBlock/wiki/Static-filter-syntax",
|
||||
"Name": "uBlock Origin"
|
||||
},
|
||||
{
|
||||
"Id": 6,
|
||||
"DefinitionUrl": "https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters",
|
||||
"Name": "AdGuard"
|
||||
},
|
||||
{
|
||||
"Id": 7,
|
||||
"DefinitionUrl": null,
|
||||
"Name": "Exceptions (Whitelist)"
|
||||
},
|
||||
{
|
||||
"Id": 8,
|
||||
"DefinitionUrl": null,
|
||||
"Name": "URLs"
|
||||
},
|
||||
{
|
||||
"Id": 9,
|
||||
"DefinitionUrl": null,
|
||||
"Name": "IPs"
|
||||
}
|
||||
]
|
||||
Loading…
Reference in a new issue