MonodroidStockPortfolio/MonoStockPortfolio/Framework/ServiceLocator.cs

29 lines
1.2 KiB
C#
Raw Normal View History

using System;
using Android.Content;
2011-01-03 02:00:10 +00:00
using MonoStockPortfolio.Core.Config;
using MonoStockPortfolio.Core.PortfolioRepositories;
using MonoStockPortfolio.Core.Services;
using MonoStockPortfolio.Core.StockData;
using MonoStockPortfolio.Presenters;
namespace MonoStockPortfolio.Framework
{
public static class ServiceLocator
{
public static Context Context { get; set; }
2011-02-06 01:48:55 +00:00
static ServiceLocator()
{
IttyBittyIoC.Register<IMainPresenter>(() => new MainPresenter(new AndroidSqlitePortfolioRepository(Context)));
IttyBittyIoC.Register<IStockDataProvider>(() => new YahooStockDataProvider());
IttyBittyIoC.Register<IPortfolioService>(() => new PortfolioService(new AndroidSqlitePortfolioRepository(Context), new YahooStockDataProvider()));
2011-02-06 01:48:55 +00:00
IttyBittyIoC.Register<IPortfolioRepository>(() => new AndroidSqlitePortfolioRepository(Context));
IttyBittyIoC.Register<IConfigRepository>(() => new AndroidSqliteConfigRepository(Context));
}
2011-02-06 01:48:55 +00:00
public static object Get(Type serviceType)
{
2011-02-06 01:48:55 +00:00
return IttyBittyIoC.Resolve(serviceType);
}
}
}