view Agendas/trunk/src/Agendas.Repositories.Memory/RepositoryBase.cs @ 61:cb3f7b47c1f0

Relación de Ponente a Eventos de los que es el ponente.
author nelopauselli
date Tue, 17 May 2011 01:27:03 -0300
parents 65bbcdd5d357
children 2d1adbaf0373
line wrap: on
line source

using System;
using System.Collections.Generic;
using AltNetHispano.Agendas.Domain;

namespace AltNetHispano.Agendas.Repositories.Memory
{
	public class RepositoryBase<T> where T : Identificable
	{
		protected static readonly IDictionary<Guid, T> Objects = new Dictionary<Guid, T>();

		public void Save(T obj)
		{
			if (obj.Id==Guid.Empty)
			{
				var setter = typeof (Identificable).GetProperty("Id");
				setter.SetValue(obj, Guid.NewGuid(), null);
			}

			if (!Objects.Keys.Contains(obj.Id))
				Objects.Add(obj.Id, obj);
		}

	}
}