Is it possible to inject dependency into PostSharp aspect? I'd like to create NavigateBackAspect - something like that:
[PSerializable]
class NavigateBackAspect : OnMethodBoundaryAspect
{
private readonly INavigationService _navigationService;
public NavigateBackAspect(INavigationService navigationService)
{
_navigationService = navigationService;
}
public override void OnExit(MethodExecutionArgs args)
{
base.OnExit(args);
var viewModel = args.Instance as Shared.ViewModel.ViewModel;
if (viewModel != null)
{
viewModel.Dispose();
_navigationService.GoBack();
}
}
}
However I've read that constructor/parameter injection is not possible because constructor is called just once after compilation. Are there any workarounds?