/// <summary>Selects the MemoryStore that must be used. If the specified DataSourceInfo contains a valid MemoryStore, it is used; otherwise the /// value of the property 'MemoryStore' is used.</summary> /// <param name="dataSourceInfo">Any information regarding the data store that is used as data source.</param> /// <returns>The MemoryStore that must be used.</returns> private MemoryStore <TEntity> SelectMemoryStore(DataSourceInfo dataSourceInfo) { if (MemorySourceInfo.IsMemoryStoreSpecified(dataSourceInfo)) { return(MemorySourceInfo.SelectMemoryStore <TEntity>(dataSourceInfo)); } else { return(this.MemoryStore); } }
/// <summary>Initializes a new instance of the <see cref="MemoryRepository{TEntity}"/> class using the specified <see cref="DataSourceInfo"/>. /// </summary> /// <param name="dataSourceInfo">The data source information that must be used to access the data source.</param> /// <exception cref="InvalidOperationException"><paramref name="dataSourceInfo"/> does not specify a valid <see cref="Enkoni.Framework.Entities.MemoryStore{T}"/>. /// </exception> public MemoryRepository(DataSourceInfo dataSourceInfo) : base(dataSourceInfo) { /* Initializes the internal collections */ this.additionCache = new List <TEntity>(); this.updateCache = new List <TEntity>(); this.deletionCache = new List <TEntity>(); this.MemoryStore = MemorySourceInfo.SelectMemoryStore <TEntity>(dataSourceInfo); if (this.MemoryStore == null) { throw new InvalidOperationException("The memory store is mandatory."); } }