mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2025-01-01 11:13:19 +00:00
26 lines
No EOL
789 B
C#
26 lines
No EOL
789 B
C#
using Android.Content;
|
|
using PostSharp.Aspects;
|
|
|
|
namespace MonoStockPortfolio.Framework
|
|
{
|
|
public class IoCAttribute : LocationInterceptionAspect
|
|
{
|
|
public override void OnGetValue(LocationInterceptionArgs args)
|
|
{
|
|
if (ServiceLocator.Context == null)
|
|
{
|
|
var activityContext= (Context)args.Instance;
|
|
ServiceLocator.Context = activityContext.ApplicationContext.ApplicationContext;
|
|
}
|
|
|
|
var locationType = args.Location.LocationType;
|
|
var instantiation = ServiceLocator.Get(locationType);
|
|
|
|
if(instantiation != null)
|
|
{
|
|
args.SetNewValue(instantiation);
|
|
}
|
|
args.ProceedGetValue();
|
|
}
|
|
}
|
|
} |