/
PeopleRepository.cs
33 lines (27 loc) · 967 Bytes
/
PeopleRepository.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PeopleFinder {
public interface IRepository<out T> where T : DomainObject {
IEnumerable<T> GetAll();
}
public class PersonRepository : IRepository<Person> {
private static IEnumerable<Person> _people;
private static IEnumerable<Person> GetPeople() {
if (_people != null) return _people;
_people = new List<Person>
{
new Person {FirstName = "John", LastName = "Doe"},
new Person {FirstName = "Jane", LastName = "Doe"},
new Person {FirstName = "John", LastName = "Smith"},
new Person {FirstName = "Matthew", LastName = "MacDonald"},
new Person {FirstName = "Andrew", LastName = "MacDonald"}
};
return _people;
}
public IEnumerable<Person> GetAll() {
return GetPeople();
}
}
}