예제 #1
0
 public Repository(InMemoryDbTable <TKey, TEntity> table)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     _table = table;
 }
예제 #2
0
        public InMemoryDbTable <TKey, TEntity> GetTable <TKey, TEntity>() where TEntity : class, IKeyed <TKey>
        {
            InMemoryDbTable <TKey, TEntity> table;

            Type   type = typeof(TEntity);
            Type   key  = typeof(TKey);
            string hash = type + key.ToString();

            if (_tables.ContainsKey(hash))
            {
                table = (InMemoryDbTable <TKey, TEntity>)_tables[hash];
            }
            else
            {
                table         = new InMemoryDbTable <TKey, TEntity>();
                _tables[hash] = table;
            }

            return(table);
        }
예제 #3
0
        public IKeyedReadOnlyRepository <TKey, TEntity> CreateKeyedReadOnlyRepository <TKey, TEntity>() where TEntity : class, IKeyed <TKey>
        {
            InMemoryDbTable <TKey, TEntity> table = _db.GetTable <TKey, TEntity>();

            return(new Repository <TKey, TEntity>(table));
        }