Esempio n. 1
0
        public ObservableGroup(IEventSystem eventSystem, ObservableGroupToken token, IEnumerable <IEntity> initialEntities)
        {
            Token       = token;
            EventSystem = eventSystem;

            _onEntityAdded   = new Subject <IEntity>();
            _onEntityRemoved = new Subject <IEntity>();

            CachedEntities = initialEntities.ToDictionary(x => x.Id, x => x);
            Subscriptions  = new List <IDisposable>();

            MonitorEntityChanges();
        }
Esempio n. 2
0
        public ObservableGroup(ObservableGroupToken token, IEnumerable <IEntity> initialEntities, INotifyingEntityCollection notifyingCollection)
        {
            Token = token;
            NotifyingCollection = notifyingCollection;

            _onEntityAdded    = new Subject <IEntity>();
            _onEntityRemoved  = new Subject <IEntity>();
            _onEntityRemoving = new Subject <IEntity>();

            Subscriptions  = new List <IDisposable>();
            CachedEntities = initialEntities.Where(x => Token.LookupGroup.Matches(x)).ToDictionary(x => x.Id, x => x);

            MonitorEntityChanges();
        }
Esempio n. 3
0
        public ObservableGroup(ObservableGroupToken token, IEnumerable <IEntity> initialEntities, IEnumerable <INotifyingEntityCollection> notifyingCollections)
        {
            Token = token;
            NotifyingCollections = notifyingCollections;

            _onEntityAdded    = new Subject <IEntity>();
            _onEntityRemoved  = new Subject <IEntity>();
            _onEntityRemoving = new Subject <IEntity>();

            Subscriptions = new List <IDisposable>();
            var applicableEntities = initialEntities.Where(x => Token.LookupGroup.Matches(x));

            CachedEntities = new EntityLookup();

            foreach (var applicableEntity in applicableEntities)
            {
                CachedEntities.Add(applicableEntity);
            }

            NotifyingCollections.ForEachRun(MonitorEntityChanges);
        }