Пример #1
0
        // private Dictionary<string, Filter<TDomainClass>> _filters;

        /// <summary>
        /// Sets up the catalog as a paired collection and source
        /// </summary>
        /// <param name="collection">
        /// In-memory collection of domain objects
        /// </param>
        /// <param name="source"></param>
        /// Source for loading/saving domain objects
        /// <param name="loadWhenCreated"></param>
        public CatalogBase(CollectionBase <TDomainClass> collection,
                           SourceBase <TDomainClass> source,
                           bool loadWhenCreated = false)
        {
            // Sanity checks, so we don't need null checks elsewhere
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _source        = source;
            _collection    = collection;
            _filterManager = new FilterManager <TDomainClass>();

            Modified = true;

            if (loadWhenCreated)
            {
                Load();
            }
        }
Пример #2
0
 /// <summary>
 /// Loads domain objects from the source.
 /// NB: Note that exceptions are catched and ignored
 /// </summary>
 public async void Load()
 {
     try
     {
         _collection = await _source.Load();
     }
     catch (Exception)
     {
         // ignored
     }
     InvokeObjectCreated();
 }
Пример #3
0
 /// <summary>
 /// Loads domain objects from the source.
 /// NB: Note that exceptions are catched and ignored
 /// </summary>
 public async void Load()
 {
     try
     {
         _collection = await _source.Load();
     }
     catch (Exception)
     {
         // ignored
     }
     Modified = true;
 }
Пример #4
0
        /// <summary>
        /// Sets up the model as a paired collection and source
        /// </summary>
        /// <param name="collection">
        /// In-memory collection of domain objects
        /// </param>
        /// <param name="source"></param>
        /// Source for loading/saving domain objects
        /// <param name="loadWhenCreated"></param>
        public DomainModelBase(CollectionBase <TDomainClass> collection,
                               SourceBase <TDomainClass> source,
                               bool loadWhenCreated = false)
        {
            _source     = source;
            _collection = collection;
            Modified    = true;

            if (loadWhenCreated)
            {
                Load();
            }
        }
Пример #5
0
        /// <summary>
        /// Sets up the catalog as a paired collection and source
        /// </summary>
        /// <param name="collection">
        /// In-memory collection of domain objects
        /// </param>
        /// <param name="source"></param>
        /// Source for loading/saving domain objects
        public CatalogBase(CollectionBase <TDomainClass> collection, SourceBase <TDomainClass> source)
        {
            // Sanity checks, so we don't need null checks elsewhere
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _source        = source;
            _collection    = collection;
            _filterManager = new FilterManager <TDomainClass>();

            AppConfig.LoadCatalogs += Load;
            AppConfig.SaveCatalogs += Save;
        }