导航

10- ActionInvokerProviderContext,

Posted on 2015-04-16 15:00  DotNet1010  阅读(175)  评论(0)    收藏  举报

 

  public interface IActionInvoker
    {
        Task InvokeAsync();
    }

 

     public interface INestedProviderManager<T>
	{
		void Invoke(T context);
	}

 ---------------

  public class ActionInvokerProviderContext
    {
        public ActionInvokerProviderContext([NotNull]ActionContext actionContext)
        {
            ActionContext = actionContext;
        }

        public ActionContext ActionContext { get; private set; }

        public IActionInvoker Result { get; set; }
    }

 

public class NestedProviderManager<T> : INestedProviderManager<T>
	{
		public NestedProviderManager(IEnumerable<INestedProvider<T>> providers);

		public void Invoke(T context);
	}

 

 yield return describe.Transient<INestedProvider<ActionInvokerProviderContext>,
                                            ControllerActionInvokerProvider>(); 

 

  public class ActionInvokerFactory : IActionInvokerFactory
    {
        private readonly INestedProviderManager<ActionInvokerProviderContext> _actionInvokerProvider;

        public ActionInvokerFactory(INestedProviderManager<ActionInvokerProviderContext> actionInvokerProvider)
        {
            _actionInvokerProvider = actionInvokerProvider;
        }

        public IActionInvoker CreateInvoker(ActionContext actionContext)
        {
            var context = new ActionInvokerProviderContext(actionContext);
            _actionInvokerProvider.Invoke(context);
            return context.Result;
        }
    }