public static void Unsubscribe(string tableName, ChangesTcpService tcpService) { lock (Subscribers) { if (!Subscribers.ContainsKey(tableName)) { return; } Subscribers[tableName] = Subscribers[tableName].RemoveFromReadOnlyList(itm => itm.Id == tcpService.Id); } }
public static void Subscribe(string tableName, ChangesTcpService changes) { lock (Subscribers) { if (!Subscribers.ContainsKey(tableName)) { Subscribers.Add(tableName, new[] { changes }); return; } Subscribers[tableName] = Subscribers[tableName].AddToReadOnlyList(changes); } }