mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
move rule parsing to Snapshot class
This commit is contained in:
parent
3a443e7e43
commit
c1772a8680
1 changed files with 10 additions and 5 deletions
|
|
@ -70,10 +70,9 @@ private void AddOrUpdateRules(IEnumerable<Snapshot> snapshots)
|
|||
private void AddOrUpdateRules(Snapshot snapshot)
|
||||
{
|
||||
// add new Rules
|
||||
var snapshotRulesRaw =
|
||||
snapshot.Content.Split(new[] {"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var preExistingSnapshotRules = filterListsDbContext.Rules.Where(x => snapshotRulesRaw.Contains(x.Raw));
|
||||
var newSnapshotRulesRaw = snapshotRulesRaw.Except(preExistingSnapshotRules.Select(x => x.Raw));
|
||||
snapshot.ParseRawRules();
|
||||
var preExistingSnapshotRules = filterListsDbContext.Rules.Where(x => snapshot.RawRules.Contains(x.Raw));
|
||||
var newSnapshotRulesRaw = snapshot.RawRules.Except(preExistingSnapshotRules.Select(x => x.Raw));
|
||||
var newSnapshotRules =
|
||||
newSnapshotRulesRaw.Select(newSnapshotRuleRaw => new Rule {Raw = newSnapshotRuleRaw});
|
||||
filterListsDbContext.Rules.AddRange(newSnapshotRules);
|
||||
|
|
@ -109,8 +108,14 @@ private class FilterListDto
|
|||
|
||||
private class Snapshot
|
||||
{
|
||||
public string Content { get; set; }
|
||||
public string Content { private get; set; }
|
||||
public int FilterListId { get; set; }
|
||||
public string[] RawRules { get; private set; }
|
||||
|
||||
public void ParseRawRules()
|
||||
{
|
||||
RawRules = Content.Split(new[] {"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue