MonodroidStockPortfolio/MonoStockPortfolio/Framework/ServiceLocator.cs

28 lines
No EOL
1.1 KiB
C#

using System;
using Android.Content;
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()
{
//IttyBittyIoC.Register(Context);
IttyBittyIoC.Register<IStockDataProvider>(() => new GoogleStockDataProvider());
IttyBittyIoC.Register<IPortfolioService>(() => new PortfolioService(new AndroidSqlitePortfolioRepository(Context), new GoogleStockDataProvider()));
IttyBittyIoC.Register<IPortfolioRepository>(() => new AndroidSqlitePortfolioRepository(Context));
IttyBittyIoC.Register<IConfigRepository>(() => new AndroidSqliteConfigRepository(Context));
}
public static object Get(Type serviceType)
{
return IttyBittyIoC.Resolve(serviceType);
}
}
}