annotate Agendas/trunk/src/Agendas.Repositories.Memory/RepositoryBase.cs @ 288:a6037c6c88d8

Se soluciona bug #198 Bug: Summary incorrecto en Google Calendar. Se parametriza la hora en el mensaje.
author user@MECHUQUE
date Mon, 30 Jan 2012 01:52:47 -0300
parents 2d1adbaf0373
children
rev   line source
4
49b572535156 proponer van
nelopauselli
parents:
diff changeset
1 using System;
49b572535156 proponer van
nelopauselli
parents:
diff changeset
2 using System.Collections.Generic;
56
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
3 using AltNetHispano.Agendas.Domain;
4
49b572535156 proponer van
nelopauselli
parents:
diff changeset
4
34
475be11edf56 Ajuste en los nombre de los assemblies y namespaces
nelo@MTEySS.neluz.int
parents: 4
diff changeset
5 namespace AltNetHispano.Agendas.Repositories.Memory
4
49b572535156 proponer van
nelopauselli
parents:
diff changeset
6 {
56
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
7 public class RepositoryBase<T> where T : Identificable
4
49b572535156 proponer van
nelopauselli
parents:
diff changeset
8 {
49b572535156 proponer van
nelopauselli
parents:
diff changeset
9 protected static readonly IDictionary<Guid, T> Objects = new Dictionary<Guid, T>();
56
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
10
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
11 public T Get(Guid id)
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
12 {
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
13 T value;
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
14 return Objects.TryGetValue(id, out value) ? value : null;
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
15 }
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
16
56
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
17 public void Save(T obj)
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
18 {
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
19 if (obj.Id==Guid.Empty)
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
20 {
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
21 var setter = typeof (Identificable).GetProperty("Id");
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
22 setter.SetValue(obj, Guid.NewGuid(), null);
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
23 }
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
24
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
25 if (!Objects.Keys.Contains(obj.Id))
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
26 Objects.Add(obj.Id, obj);
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
27 }
65bbcdd5d357 Pasando la responsabilidad de generar el Id al repositorio
nelopauselli
parents: 34
diff changeset
28
137
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
29 public void Delete(T obj)
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
30 {
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
31 Objects.Remove(obj.Id);
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
32 }
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
33
2d1adbaf0373 CRUD de Patrocinador
nelopauselli
parents: 56
diff changeset
34
4
49b572535156 proponer van
nelopauselli
parents:
diff changeset
35 }
49b572535156 proponer van
nelopauselli
parents:
diff changeset
36 }