MonodroidStockPortfolio/MonoStockPortfolio/Framework/ServiceLocator.cs

44 lines
1.5 KiB
C#
Raw Normal View History

using System;
using Android.Content;
using Android.Util;
using MonoStockPortfolio.Activites.MainScreen;
using MonoStockPortfolio.Activites.PortfolioScreen;
2011-01-03 02:00:10 +00:00
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; }
2011-02-06 01:48:55 +00:00
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>();
}
2011-02-06 01:48:55 +00:00
public static object Get(Type serviceType)
{
try
{
return IttyBittyIoC.Resolve(serviceType);
}
catch (Exception)
{
Log.Error("ServiceLocatorGet", "Unable to resolve type: " + serviceType.Name);
throw;
}
}
}
}