Exemplo n.º 1
0
        public void Unlink(ISessionDefinitionsSource collection)
        {
            if (collection != null && _linkedCollections.Contains(collection))
            {
                _linkedCollections.Remove(collection);

                collection.DefinitionsChanged -= LinkedCollection_DefinitionsChanged;

                if (collection.Definitions.Any())
                {
                    DefinitionsChanged?.Invoke(this, CollectionChangedEventArgs <SessionDefinition> .CreateForRemovedCollection(collection.Definitions));
                }
            }
        }
Exemplo n.º 2
0
        //public void AddRange(IEnumerable<SessionDefinition> definitions)
        //{
        //    var newDefinitions = definitions.Where(d => _definitions.Contains(d) == false).ToList();

        //    if (newDefinitions.Any())
        //    {
        //        _definitions.AddRange(newDefinitions);

        //        DefinitionsChanged?.Invoke(this, CollectionChangedEventArgs<SessionDefinition>.CreateForAddedCollection(definitions));
        //    }
        //}


        //public void Add(SessionDefinition definition)
        //{
        //    if (_definitions.Contains(definition) == false)
        //    {
        //        _definitions.Add(definition);

        //        DefinitionsChanged?.Invoke(this, CollectionChangedEventArgs<SessionDefinition>.CreateForAddedItem(definition));
        //    }
        //}


        //public void Delete(SessionDefinition session)
        //{
        //    if (_definitions.Remove(session))
        //    {
        //        DefinitionsChanged?.Invoke(this, CollectionChangedEventArgs<SessionDefinition>.CreateForRemovedItem(session));
        //    }
        //}


        public void Link(ISessionDefinitionsSource collection)
        {
            collection.ThrowIfNull(nameof(collection));

            if (_linkedCollections.Contains(collection) == false)
            {
                _linkedCollections.Add(collection);

                collection.DefinitionsChanged += LinkedCollection_DefinitionsChanged;

                if (collection.Definitions.Any())
                {
                    DefinitionsChanged?.Invoke(this, CollectionChangedEventArgs <SessionDefinition> .CreateForAddedCollection(collection.Definitions));
                }
            }
        }