Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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;
        }