///<inheritdoc/> public void AddTableListenerEx(Action <ITable, string, Value, NotifyFlags> listenerDelegate, NotifyFlags flags) { List <int> adapters; if (!m_actionListenerMap.TryGetValue(listenerDelegate, out adapters)) { adapters = new List <int>(); m_actionListenerMap.Add(listenerDelegate, adapters); } // ReSharper disable once InconsistentNaming EntryListenerCallback func = (uid, key, value, flags_) => { string relativeKey = key.Substring(m_path.Length + 1); if (relativeKey.IndexOf(PathSeperatorChar) != -1) { return; } listenerDelegate(this, relativeKey, value, flags_); }; int id = NtCore.AddEntryListener(m_path + PathSeperatorChar, func, flags); adapters.Add(id); }
///<inheritdoc/> public void AddTableListenerEx(string key, Action <ITable, string, Value, NotifyFlags> listenerDelegate, NotifyFlags flags) { lock (m_actionListenerMap) { if (!m_actionListenerMap.TryGetValue(listenerDelegate, out List <int> adapters)) { adapters = new List <int>(); m_actionListenerMap.Add(listenerDelegate, adapters); } string fullKey = m_pathWithSeperator + key; // ReSharper disable once InconsistentNaming EntryListenerCallback func = (uid, funcKey, value, flags_) => { if (!funcKey.Equals(fullKey)) { return; } listenerDelegate(this, key, value, flags_); }; int id = NtCore.AddEntryListener(fullKey, func, flags); adapters.Add(id); } }
///<inheritdoc/> public void AddTableListenerEx(ITableListener listener, NotifyFlags flags) { lock (m_listenerMap) { if (!m_listenerMap.TryGetValue(listener, out List <int> adapters)) { adapters = new List <int>(); m_listenerMap.Add(listener, adapters); } // ReSharper disable once InconsistentNaming EntryListenerCallback func = (uid, key, value, flags_) => { string relativeKey = key.Substring(m_path.Length + 1); if (relativeKey.IndexOf(PathSeperatorChar) != -1) { return; } listener.ValueChanged(this, relativeKey, value, flags_); }; int id = NtCore.AddEntryListener(m_pathWithSeperator, func, flags); adapters.Add(id); } }
///<inheritdoc/> public void AddSubTableListener(Action <ITable, string, Value, NotifyFlags> listenerDelegate, bool localNotify) { List <int> adapters; if (!m_actionListenerMap.TryGetValue(listenerDelegate, out adapters)) { adapters = new List <int>(); m_actionListenerMap.Add(listenerDelegate, adapters); } HashSet <string> notifiedTables = new HashSet <string>(); // ReSharper disable once InconsistentNaming EntryListenerCallback func = (uid, key, value, flags_) => { string relativeKey = key.Substring(m_path.Length + 1); int endSubTable = relativeKey.IndexOf(PathSeperatorChar); if (endSubTable == -1) { return; } string subTableKey = relativeKey.Substring(0, endSubTable); if (notifiedTables.Contains(subTableKey)) { return; } notifiedTables.Add(subTableKey); listenerDelegate(this, subTableKey, null, flags_); }; NotifyFlags flags = NotifyFlags.NotifyNew | NotifyFlags.NotifyUpdate; if (localNotify) { flags |= NotifyFlags.NotifyLocal; } int id = NtCore.AddEntryListener(m_path + PathSeperatorChar, func, flags); adapters.Add(id); }
///<inheritdoc/> public void AddTableListenerEx(string key, ITableListener listener, NotifyFlags flags) { List <int> adapters; if (!m_listenerMap.TryGetValue(listener, out adapters)) { adapters = new List <int>(); m_listenerMap.Add(listener, adapters); } string fullKey = m_path + PathSeperatorChar + key; // ReSharper disable once InconsistentNaming EntryListenerCallback func = (uid, funcKey, value, flags_) => { if (!funcKey.Equals(fullKey)) { return; } listener.ValueChanged(this, key, value, flags_); }; int id = NtCore.AddEntryListener(fullKey, func, flags); adapters.Add(id); }