title: injectiong an instance of ApplicationModel into an MVC service which will itself be a singleton
body: <p>I would like to display components of a navigation tree only if a principal has access to those components (whether roles or policy based).</p>
  
  <p>I am not particularly familiar with MVC core, but reading to date would indicate that I could build a list of what authorization filters will be applied to an action with something like:</p>
  
  <pre><code>    public NavigationNodePermissionResolver(ApplicationModel appModel)
      {
          foreach (var controllerModel in appModel.Controllers)
          {
              var contextFilters = controllerModel.Filters.OfType&lt;IAsyncAuthorizationFilter&gt;().ToList();
              foreach (ActionModel action in controllerModel.Actions)//todo restrain to HttpGet
              {
                  var actionFilters = action.Filters.OfType&lt;IAsyncAuthorizationFilter&gt;().ToList();
              }
          }
  </code></pre>
  
  <p>How can I inject an instance of the application model into the instantiator for NavigationNodePermissionResolver? </p>
  
  <p>NavigationNodePermissionResolver itself will be injectable as:</p>
  
  <pre><code>services.TryAddSingleton&lt;INavigationNodePermissionResolver, NavigationNodePermissionResolver&gt;();
  </code></pre>
  
  <p><strong>edit</strong></p>
  
  <p>the follow on to this question - what to do when I have a list of the IAsyncAuthorizationFilters is <a href="https://stackoverflow.com/questions/45023530/test-if-call-to-iasyncauthorizationfilter-onauthorizationasync-has-failed">in this so question</a>.</p>
  
  <p>as follow up information the ApplicationModel is a property of the ApplicationModelProviderContext which I found out about in <a href="https://stackoverflow.com/questions/35825021/override-global-authorize-filter-in-asp-net-core-mvc-1-0#35863514">this SO answer</a> - it does seem to be roughly what I am after, but it may be the approach I am using to obtain and then execute authorization filters is completely wrong</p>