private void Apply(Entity entity) { if (_idToFilterData.TryGetValue(entity.UniqueIdentifier, out FilterDataT filterData)) { FilterDataT updatedFilterData = new FilterDataT(); if (!updatedFilterData.TrySetFilterData(entity, _refresher.EntityAdmin)) { _idToFilterData.Remove(entity.UniqueIdentifier); var listeners = _listeners.ToArray(); for (int i = 0, c = listeners.Length; i < c; i++) { listeners[i].OnDataUnregistered(filterData); } DataRemovedEvent?.Invoke(entity.UniqueIdentifier, filterData); } else if (!updatedFilterData.Equals(filterData)) { _idToFilterData[entity.UniqueIdentifier] = updatedFilterData; var listeners = _listeners.ToArray(); for (int i = 0, c = listeners.Length; i < c; i++) { listeners[i].OnDataUnregistered(filterData); } DataUpdatedEvent?.Invoke(entity.UniqueIdentifier, updatedFilterData); } } else { filterData = new FilterDataT(); if (filterData.TrySetFilterData(entity, _refresher.EntityAdmin)) { _idToFilterData[entity.UniqueIdentifier] = filterData; var listeners = _listeners.ToArray(); for (int i = 0, c = listeners.Length; i < c; i++) { listeners[i].OnDataRegistered(filterData); } DataAddedEvent?.Invoke(entity.UniqueIdentifier, filterData); } } }
public void PublishDataAddedEvent() { DataAddedEvent?.Invoke(this, EventArgs.Empty); }