public void Add <T>(T item) where T : IEntity { MockTable <IEntity> table = GetTypeTable(typeof(T)); table.Add(item); }
public bool Exists <T>(T item) where T : IEntity { MockTable <IEntity> table = GetTypeTable(typeof(T)); return(table.Exists(item.EntityId)); }
private MockTable <IEntity> GetTypeTable(Type type) { MockTable <IEntity> table; if (!Tables.TryGetValue(type, out table)) { table = new MockTable <IEntity>(); Tables[type] = table; } return(table); }
static public IEnumerable <T> Where <T>( this MockTable <T> items, Predicate <T> func) where T : IEntity { if (func == null) { throw new ArgumentNullException( "Predicate 'func' should not be null"); } foreach (T item in items) { if (func(item)) { yield return(item); } } }