MonodroidStockPortfolio/MonoStockPortfolio/Framework/ServiceLocator.cs

88 lines
2.6 KiB
C#
Raw Normal View History

using System;
2011-02-03 12:09:03 +00:00
using System.Collections.Generic;
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;
2011-02-03 12:09:03 +00:00
using MonoStockPortfolio.Entities;
using TinyIoC;
namespace MonoStockPortfolio.Framework
{
public static class ServiceLocator
{
public static Context Context { get; set; }
private static TinyIoCContainer _container;
public static object Get(Type serviceType)
{
if (_container == null)
{
_container = RegisterTypes();
}
return _container.Resolve(serviceType);
}
private static TinyIoCContainer RegisterTypes()
{
var container = TinyIoCContainer.Current;
container.Register<Context>(Context);
2011-02-03 12:09:03 +00:00
container.Register<IStockDataProvider, DummyStockDataProvider>().AsMultiInstance(); // works
container.Register<IPortfolioService, PortfolioService>().AsMultiInstance(); // works
container.Register<IPortfolioRepository, Whatever>().AsMultiInstance(); // error
//container.Register<IConfigRepository, AndroidSqliteConfigRepository>().AsMultiInstance(); // error
return container;
}
}
2011-02-03 12:09:03 +00:00
public class Whatever : IPortfolioRepository
{
public IList<Portfolio> GetAllPortfolios()
{
throw new NotImplementedException();
}
public void SavePortfolio(Portfolio portfolio)
{
throw new NotImplementedException();
}
public void DeletePortfolioById(int portfolioId)
{
throw new NotImplementedException();
}
public Portfolio GetPortfolioById(long portfolioId)
{
throw new NotImplementedException();
}
public Portfolio GetPortfolioByName(string portfolioName)
{
throw new NotImplementedException();
}
public IList<Position> GetAllPositions(long portfolioId)
{
throw new NotImplementedException();
}
public void SavePosition(Position position)
{
throw new NotImplementedException();
}
public void DeletePositionById(long positionId)
{
throw new NotImplementedException();
}
public Position GetPositionById(long positionId)
{
throw new NotImplementedException();
}
}
}