2011-01-02 22:27:28 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Android.Content;
|
2011-03-15 01:42:26 +00:00
|
|
|
|
using Android.Util;
|
2011-03-17 03:05:49 +00:00
|
|
|
|
using MonoStockPortfolio.Activites.EditPortfolioScreen;
|
2011-03-15 01:42:26 +00:00
|
|
|
|
using MonoStockPortfolio.Activites.MainScreen;
|
|
|
|
|
using MonoStockPortfolio.Activites.PortfolioScreen;
|
2011-01-03 02:00:10 +00:00
|
|
|
|
using MonoStockPortfolio.Core.Config;
|
2011-01-02 22:27:28 +00:00
|
|
|
|
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()
|
2011-01-02 22:27:28 +00:00
|
|
|
|
{
|
2011-03-06 18:46:04 +00:00
|
|
|
|
// services/repositories
|
2011-03-15 01:42:26 +00:00
|
|
|
|
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-03-17 03:05:49 +00:00
|
|
|
|
IttyBittyIoC.Register<IEditPortfolioPresenter, EditPortfolioPresenter>();
|
2011-01-02 22:27:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-06 01:48:55 +00:00
|
|
|
|
public static object Get(Type serviceType)
|
2011-01-02 22:27:28 +00:00
|
|
|
|
{
|
2011-03-15 01:42:26 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return IttyBittyIoC.Resolve(serviceType);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
Log.Error("ServiceLocatorGet", "Unable to resolve type: " + serviceType.Name);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2011-01-02 22:27:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|