/// <inheritdoc /> public void InsertAll(List <T> objects, KeyManagementStrategyType keyManagement = KeyManagementStrategyType.CollectionDecides) { foreach (var obj in objects) { Insert(obj, keyManagement); } }
/// <inheritdoc /> public void ReplaceAll(List <TDomainData> objects, KeyManagementStrategyType keyManagement = KeyManagementStrategyType.CollectionDecides) { RemoveAll(); foreach (var obj in objects) { Insert(obj, keyManagement); } }
public PersistableCatalog( IInMemoryCollection <T> collection, IPersistentSource <T> source, List <PersistencyOperations> supportedOperations, KeyManagementStrategyType keyManagementStrategy = KeyManagementStrategyType.CollectionDecides) : base(collection, source, supportedOperations, keyManagementStrategy) { }
protected PersistableCatalogFull( IInMemoryCollection <TDomainData> collection, IPersistentSource <TPersistentData> source, List <PersistencyOperations> supportedOperations, KeyManagementStrategyType keyManagementStrategy = KeyManagementStrategyType.CollectionDecides) : base(collection, source, supportedOperations, keyManagementStrategy) { _persistentSource = source; }
/// <inheritdoc /> public int Insert(T obj, KeyManagementStrategyType keyManagement = KeyManagementStrategyType.CollectionDecides) { if (keyManagement == KeyManagementStrategyType.CollectionDecides) { obj.Key = NextKey(); } _collection.Add(obj.Key, obj); return(obj.Key); }
/// <summary> /// Creates a new domain object in the catalog, /// based on the data provided in the TVMO object /// </summary> /// <param name="vmObj"> /// Object containing data for domain object creation /// </param> /// <param name="keyManagement"> /// Strategy for selecting the key for the new domain object /// </param> public void Create(TVMO vmObj, KeyManagementStrategyType keyManagement = KeyManagementStrategyType.CollectionDecides) { // Create the new domain object (this is where it happens :-)). T obj = CreateDomainObjectFromVMO(vmObj); // Strategy for key selection (DataSource decides) // 1) Throw exception if Create operation is not supported, // since choosing DataSourceDecides is then meaningless. // 2) Call Create on data source, and use returned key value // as the new key for the object. // 3) Call Insert on the in-memory collection. if (keyManagement == KeyManagementStrategyType.DataSourceDecides) { if (!_supportedOperations.Contains(PersistencyOperations.Create)) { throw new NotSupportedException("The referenced data source does not support Create."); } obj.Key = _source.Create(CreateDTO(obj)).Result; _collection.Insert(obj, keyManagement); } // Strategy for key selection (Caller decides) // 1) If the data source supports the Create operation, // call Create on data source. It is assumed that it // is NOT an error to call this method, even if the // data source does not support it. // 2) Call Insert on the in-memory collection. if (keyManagement == KeyManagementStrategyType.CallerDecides) { if (_supportedOperations.Contains(PersistencyOperations.Create)) { _source.Create(CreateDTO(obj)); } _collection.Insert(obj, keyManagement); } // Strategy for key selection (Collection decides) // 1) Throw exception if Create operation is not supported, // since choosing DataSourceDecides is then meaningless. // 2) If the data source supports the Create operation, // call Create on data source. It is assumed that it // is NOT an error to call this method, even if the // data source does not support it. if (keyManagement == KeyManagementStrategyType.CollectionDecides) { obj.Key = _collection.Insert(obj, keyManagement); if (_supportedOperations.Contains(PersistencyOperations.Create)) { _source.Create(CreateDTO(obj)); } } CatalogChanged?.Invoke(obj.Key); }
protected CatalogFull( IInMemoryCollection <T> collection, IDataSourceCRUD <TPersistentData> source, List <PersistencyOperations> supportedOperations, KeyManagementStrategyType keyManagementStrategy = KeyManagementStrategyType.CollectionDecides) { _collection = collection; _source = source; _supportedOperations = supportedOperations; _keyManagementStrategy = keyManagementStrategy; }
protected RestApiCatalogFull(string url, string apiID, KeyManagementStrategyType kms) : base(new InMemoryCollection <TDomainData>(), new ConfiguredRestAPISource <TPersistentData>(url, apiID), new List <PersistencyOperations> { PersistencyOperations.Load, PersistencyOperations.Create, PersistencyOperations.Read, PersistencyOperations.Update, PersistencyOperations.Delete }, kms) { }
protected EFCoreCatalogFull(KeyManagementStrategyType kms) : base(new InMemoryCollection <TDomainData>(), new ConfiguredEFCoreSource <TDbContext, TPersistentData>(), new List <PersistencyOperations> { PersistencyOperations.Load, PersistencyOperations.Create, PersistencyOperations.Read, PersistencyOperations.Update, PersistencyOperations.Delete }, kms) { }
public RestApiCatalog(string url, string apiID, KeyManagementStrategyType kms) : base(url, apiID, kms) { }
public EFCoreCatalog(KeyManagementStrategyType kms) : base(kms) { }