Updated DBSyncWatcher
Changed delegate to pass string instead of object. Now instead of attempting to deserialize the data in DBSyncWatcher, deserialization happens in th Syncer class.
This commit is contained in:
parent
5675ea116d
commit
b2b4eeff05
1 changed files with 3 additions and 7 deletions
|
|
@ -10,7 +10,7 @@ public class DBSyncWatcher
|
|||
private FileSystemWatcher _watcher;
|
||||
public Dictionary<string, Type> WatchFiles { get; set; } = [];
|
||||
|
||||
public delegate void DatabaseChange(string db, object value);
|
||||
public delegate void DatabaseChange(string db, string value);
|
||||
public event DatabaseChange OnDatabaseChange;
|
||||
|
||||
public DBSyncWatcher(string path)
|
||||
|
|
@ -43,9 +43,7 @@ public class DBSyncWatcher
|
|||
{
|
||||
if (line == "") continue;
|
||||
var type = WatchFiles[dbName];
|
||||
var item = JsonSerializer.Deserialize(line, type);
|
||||
if (item == null) continue;
|
||||
OnDatabaseChange?.Invoke(dbName, item);
|
||||
OnDatabaseChange?.Invoke(dbName, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,9 +56,7 @@ public class DBSyncWatcher
|
|||
foreach (var line in data.Split('\n'))
|
||||
{
|
||||
var type = WatchFiles[dbName];
|
||||
var item = JsonSerializer.Deserialize(line, type);
|
||||
if (item == null) continue;
|
||||
OnDatabaseChange?.Invoke(dbName, item);
|
||||
OnDatabaseChange?.Invoke(dbName, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue