private PropertyInfo[] GetInfo(IterativeRepositoryBase <T> repository) { // remove the property Items or items because this is the list in the RepositoryBase class return(repository .GetType() .GetProperties() .Where(p => p.Name.ToLower().Equals("items") == false) .ToArray()); }
// -- methods /// <summary> /// Creates a representation of the repository for json serialization or web-views. /// The custom properties of the properties will be stored in a dictionary called Properties and /// the Items list will be copied. /// </summary> /// <param name="repository">The instance of a concretion of the repository base class with custom properties and a list of items.</param> /// <returns>The calling instance with the copied fields.</returns> public RepositoryView <T> From(IterativeRepositoryBase <T> repository) { // items Items = repository.Items; // properties var infos = GetInfo(repository); foreach (PropertyInfo pi in infos) { if (pi.CanWrite) { Properties.Add(pi.Name, pi.GetValue(repository, null)); } } return(this); }