Introduce default order for framework ordered items to be -1000

This commit is contained in:
YishaiGalatzer 2014-10-07 21:43:50 -07:00
parent 8a3e64e164
commit 67a30e491f
9 changed files with 27 additions and 16 deletions

View File

@ -28,7 +28,10 @@ namespace Microsoft.AspNet.Mvc
}
/// <inheritdoc />
public int Order { get; set; }
public int Order
{
get { return DefaultOrder.DefaultFrameworkSortOrder; }
}
/// <inheritdoc />
public void Invoke([NotNull] ActionConstraintProviderContext context, [NotNull] Action callNext)

View File

@ -17,12 +17,6 @@ namespace Microsoft.AspNet.Mvc
{
public class ControllerActionDescriptorProvider : IActionDescriptorProvider
{
/// <summary>
/// Represents the default order associated with this provider for dependency injection
/// purposes.
/// </summary>
public static readonly int DefaultOrder = 0;
// This is the default order for attribute routes whose order calculated from
// the reflected model is null.
private const int DefaultAttributeRouteOrder = 0;
@ -45,7 +39,7 @@ namespace Microsoft.AspNet.Mvc
public int Order
{
get { return DefaultOrder; }
get { return DefaultOrder.DefaultFrameworkSortOrder; }
}
public void Invoke(ActionDescriptorProviderContext context, Action callNext)

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc
public int Order
{
get { return 0; }
get { return DefaultOrder.DefaultFrameworkSortOrder; }
}
public void Invoke(ActionInvokerProviderContext context, Action callNext)

View File

@ -0,0 +1,12 @@
namespace Microsoft.AspNet.Mvc
{
public static class DefaultOrder
{
/// <summary>
/// The default order for sorting is -1000. Other framework code
/// the depends on order should be ordered between -1 to -1999.
/// User code should order at bigger than 0 or smaller than -2000.
/// </summary>
public static readonly int DefaultFrameworkSortOrder = -1000;
}
}

View File

@ -34,7 +34,11 @@ namespace Microsoft.AspNet.Mvc.Description
}
/// <inheritdoc />
public int Order { get; private set; }
public int Order
{
get { return DefaultOrder.DefaultFrameworkSortOrder; }
}
/// <inheritdoc />
public void Invoke(ApiDescriptionProviderContext context, Action callNext)

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Filters
public int Order
{
get { return 0; }
get { return DefaultOrder.DefaultFrameworkSortOrder; }
}
protected IServiceProvider ServiceProvider { get; private set; }

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc
public int Order
{
get { return 0; }
get { return DefaultOrder.DefaultFrameworkSortOrder; }
}
public void Invoke([NotNull] ViewComponentInvokerProviderContext context, [NotNull] Action callNext)

View File

@ -3,7 +3,6 @@
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc
@ -14,10 +13,9 @@ namespace Microsoft.AspNet.Mvc
public class MvcOptionsSetup : IOptionsSetup<MvcOptions>
{
/// <inheritdoc />
/// <remarks>Order is -1 to allow MvcOptionsSetup to run before a user call to SetupOptions.</remarks>
public int Order
{
get { return -1; }
get { return DefaultOrder.DefaultFrameworkSortOrder; }
}
/// <inheritdoc />

View File

@ -22,7 +22,7 @@ namespace BasicWebSite
{
get
{
return ControllerActionDescriptorProvider.DefaultOrder - 100;
return DefaultOrder.DefaultFrameworkSortOrder - 100;
}
}