Fix #4929 - Move IActionInvokerFactory from .Internal

Also added a wealth of doc comments to an area that's not currently super
well documented.
This commit is contained in:
Ryan Nowak 2016-07-01 11:20:54 -07:00
parent 15f25d569a
commit 3ed0d01eae
5 changed files with 69 additions and 15 deletions

View File

@ -5,8 +5,19 @@ using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.Abstractions
{
/// <summary>
/// Defines an interface for invoking an MVC action.
/// </summary>
/// <remarks>
/// An <see cref="IActionInvoker"/> is created for each request the MVC handles by querying the set of
/// <see cref="IActionInvokerProvider"/> instances. See <see cref="IActionInvokerProvider"/> for more information.
/// </remarks>
public interface IActionInvoker
{
/// <summary>
/// Invokes an MVC action.
/// </summary>
/// <returns>A <see cref="Task"/> which will complete when action processing has completed.</returns>
Task InvokeAsync();
}
}

View File

@ -3,6 +3,27 @@
namespace Microsoft.AspNetCore.Mvc.Abstractions
{
/// <summary>
/// Defines an interface for components that can create an <see cref="IActionInvoker"/> for the
/// current request.
/// </summary>
/// <remarks>
/// <para>
/// <see cref="IActionInvokerProvider"/> instances form a pipeline that results in the creation of an
/// <see cref="IActionInvoker"/>. The <see cref="IActionInvokerProvider"/> instances are ordered by
/// an ascending sort of the <see cref="Order"/>.
/// </para>
/// <para>
/// To create an <see cref="IActionInvoker"/>, each provider has its <see cref="OnProvidersExecuting"/> method
/// called in sequence and given the same instance of <see cref="ActionInvokerProviderContext"/>. Then each
/// provider has its <see cref="OnProvidersExecuted"/> method called in the reverse order. The result is
/// the value of <see cref="ActionInvokerProviderContext.Result"/>.
/// </para>
/// <para>
/// As providers are called in a predefined sequence, each provider has a chance to observe and decorate the
/// result of the providers that have already run.
/// </para>
/// </remarks>
public interface IActionInvokerProvider
{
/// <summary>
@ -26,8 +47,17 @@ namespace Microsoft.AspNetCore.Mvc.Abstractions
/// </remarks>
int Order { get; }
/// <summary>
/// Called to execute the provider.
/// </summary>
/// <param name="context">The <see cref="ActionInvokerProviderContext"/>.</param>
void OnProvidersExecuting(ActionInvokerProviderContext context);
/// <summary>
/// Called to execute the provider, after the <see cref="OnProvidersExecuting"/> methods of all providers,
/// have been called.
/// </summary>
/// <param name="context">The <see cref="ActionInvokerProviderContext"/>.</param>
void OnProvidersExecuted(ActionInvokerProviderContext context);
}
}

View File

@ -0,0 +1,28 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Mvc.Abstractions;
namespace Microsoft.AspNetCore.Mvc.Infrastructure
{
/// <summary>
/// Defines an interface for creating an <see cref="IActionInvoker"/> for the current request.
/// </summary>
/// <remarks>
/// The default <see cref="IActionInvokerFactory"/> implementation creates an <see cref="IActionInvoker"/> by
/// calling into each <see cref="IActionInvokerProvider"/>. See <see cref="IActionInvokerProvider"/> for more
/// details.
/// </remarks>
public interface IActionInvokerFactory
{
/// <summary>
/// Creates an <see cref="IActionInvoker"/> for the current request associated with
/// <paramref name="actionContext"/>.
/// </summary>
/// <param name="actionContext">
/// The <see cref="ActionContext"/> associated with the current request.
/// </param>
/// <returns>An <see cref="IActionInvoker"/> or <c>null</c>.</returns>
IActionInvoker CreateInvoker(ActionContext actionContext);
}
}

View File

@ -1,12 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Mvc.Abstractions;
namespace Microsoft.AspNetCore.Mvc.Internal
{
public interface IActionInvokerFactory
{
IActionInvoker CreateInvoker(ActionContext actionContext);
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
@ -9,10 +8,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Tree;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Options;
using Moq;
using Xunit;