Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Repositories.Memory/RepositoryBase.cs @ 137:2d1adbaf0373
CRUD de Patrocinador
author | nelopauselli |
---|---|
date | Thu, 28 Jul 2011 09:26:24 -0300 |
parents | 65bbcdd5d357 |
children |
comparison
equal
deleted
inserted
replaced
136:462a78196d11 | 137:2d1adbaf0373 |
---|---|
5 namespace AltNetHispano.Agendas.Repositories.Memory | 5 namespace AltNetHispano.Agendas.Repositories.Memory |
6 { | 6 { |
7 public class RepositoryBase<T> where T : Identificable | 7 public class RepositoryBase<T> where T : Identificable |
8 { | 8 { |
9 protected static readonly IDictionary<Guid, T> Objects = new Dictionary<Guid, T>(); | 9 protected static readonly IDictionary<Guid, T> Objects = new Dictionary<Guid, T>(); |
10 | |
11 public T Get(Guid id) | |
12 { | |
13 T value; | |
14 return Objects.TryGetValue(id, out value) ? value : null; | |
15 } | |
10 | 16 |
11 public void Save(T obj) | 17 public void Save(T obj) |
12 { | 18 { |
13 if (obj.Id==Guid.Empty) | 19 if (obj.Id==Guid.Empty) |
14 { | 20 { |
18 | 24 |
19 if (!Objects.Keys.Contains(obj.Id)) | 25 if (!Objects.Keys.Contains(obj.Id)) |
20 Objects.Add(obj.Id, obj); | 26 Objects.Add(obj.Id, obj); |
21 } | 27 } |
22 | 28 |
29 public void Delete(T obj) | |
30 { | |
31 Objects.Remove(obj.Id); | |
32 } | |
33 | |
34 | |
23 } | 35 } |
24 } | 36 } |