view Agendas/trunk/src/Agendas.Factories/AgendaFactory.cs @ 128:1e47bf408073

Asignacion de los publicadores configurados en web.config al factory de agenda (mediante CompositePublicador)
author jorge.rowies
date Mon, 04 Jul 2011 20:00:51 -0300
parents a456eb519e23
children
line wrap: on
line source

using System.Collections.Generic;
using Agendas.NHibernate;
using AltNetHispano.Agendas.Domain;
using AltNetHispano.Agendas.Domain.Repositories;
using AltNetHispano.Agendas.Domain.Services;
using AltNetHispano.Agendas.Repositories.NHibernate;
using AltNetHispano.Agendas.Twitter;
using NHibernate;


namespace AltNetHispano.Agendas.Factories
{
	public static class AgendaFactory
	{
		public static IPublicador Publicador { get; set; }

		private static Agenda _agenda;

		public static Agenda GetAgenda()
		{
			ISessionFactory sessionFactory = NhHelper.GetSessionFactory();
			return _agenda ??
			       (_agenda =
			        new Agenda(Publicador, new EventoRepository(sessionFactory),
			                   new PersonaRepository(sessionFactory)));
		}

		public static IPersonaRepository GetPersonaRepository()
		{
			ISessionFactory sessionFactory = NhHelper.GetSessionFactory();
			return new PersonaRepository(sessionFactory);
		}

		public static PersonaService GetPersonaService()
		{
			return new PersonaService(GetPersonaRepository());
		}
	}
}