using System.Collections.Generic; namespace ChadSoft.Data { /// /// A base class used as a temporary in-memory data store. /// ///Type to store public class InMemoryRepository : IRepository { protected readonly List repositoryData = new List(); /// /// Get all of the current objects. /// ///All of the current objects. public virtual IEnumerable GetAll() { return repositoryData; } /// /// Find the stored objects that meet a particular criteria. /// ///The criteria used to find stored objects ///Objects that meet the criteria public virtual IEnumerable Find(ICriteria criteria) { return repositoryData.FindAll(o => criteria.IsMatch(o)); } /// /// Save an object to the repository /// /// public virtual void Save(T obj) { if (repositoryData.Contains(obj)) repositoryData.Remove(obj); repositoryData.Add(obj); } } }