view Agendas/trunk/src/Agendas.Factories/AgendaFactory.cs @ 243:59f8fa2f835e

Ticket 177: Valor de Duración de VAN en 0.
author juanjose.montesdeocaarbos
date Thu, 06 Oct 2011 08:13:05 -0300
parents a36a76bd6ec3
children 72a96459f910
line wrap: on
line source

using Agendas.Blog.Impl;
using Agendas.NHibernate;
using AltNetHispano.Agendas.Domain;
using AltNetHispano.Agendas.Domain.Repositories;
using AltNetHispano.Agendas.Domain.Services;
using AltNetHispano.Agendas.Google;
using AltNetHispano.Agendas.Repositories.NHibernate;
using AltNetHispano.Agendas.Twitter;
using NHibernate;


namespace AltNetHispano.Agendas.Factories
{
	public static class AgendaFactory
	{
		private static Agenda _agenda;

		public static Agenda GetAgenda()
		{
			var publicadores =
				new CompositePublicador(new IPublicador[] {new TwitterPublicador(), new BlogPublicador(), new GooglePublicador()});

			ISessionFactory sessionFactory = NhHelper.GetSessionFactory();
			return _agenda ??
			       (_agenda =
			        new Agenda(publicadores, new EventoRepository(sessionFactory),
			                   new PersonaRepository(sessionFactory)));
		}

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

        public static IEventoRepository GetEventoRespository()
        {
            ISessionFactory sessionFactory = NhHelper.GetSessionFactory();
            return new EventoRepository(sessionFactory);
        }

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