MonodroidStockPortfolio/MonoStockPortfolio/Framework/ServiceLocator.cs
2011-03-22 00:18:30 -04:00

50 lines
No EOL
1.9 KiB
C#

using System;
using Android.Content;
using Android.Util;
using MonoStockPortfolio.Activites.ConfigScreen;
using MonoStockPortfolio.Activites.EditPortfolioScreen;
using MonoStockPortfolio.Activites.EditPositionScreen;
using MonoStockPortfolio.Activites.MainScreen;
using MonoStockPortfolio.Activites.PortfolioScreen;
using MonoStockPortfolio.Core.Config;
using MonoStockPortfolio.Core.PortfolioRepositories;
using MonoStockPortfolio.Core.Services;
using MonoStockPortfolio.Core.StockData;
namespace MonoStockPortfolio.Framework
{
public static class ServiceLocator
{
public static Context Context { get; set; }
static ServiceLocator()
{
// services/repositories
IttyBittyIoC.Register<Context>(() => Context);
IttyBittyIoC.Register<IStockDataProvider, YahooStockDataProvider>();
IttyBittyIoC.Register<IPortfolioRepository,AndroidSqlitePortfolioRepository>();
IttyBittyIoC.Register<IPortfolioService, PortfolioService>();
IttyBittyIoC.Register<IConfigRepository, AndroidSqliteConfigRepository>();
// presenters
IttyBittyIoC.Register<IMainPresenter, MainPresenter>();
IttyBittyIoC.Register<IPortfolioPresenter, PortfolioPresenter>();
IttyBittyIoC.Register<IEditPortfolioPresenter, EditPortfolioPresenter>();
IttyBittyIoC.Register<IEditPositionPresenter, EditPositionPresenter>();
IttyBittyIoC.Register<IConfigPresenter, ConfigPresenter>();
}
public static object Get(Type serviceType)
{
try
{
return IttyBittyIoC.Resolve(serviceType);
}
catch (Exception)
{
Log.Error("ServiceLocatorGet", "Unable to resolve type: " + serviceType.Name);
throw;
}
}
}
}