Rename ActionDescriptorsCollection
ActionDescriptorsCollection -> ActionDescriptorCollection
This commit is contained in:
parent
9168cd1f37
commit
ff00c07b85
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Mvc.ApiExplorer
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public class ApiDescriptionGroupCollectionProvider : IApiDescriptionGroupCollectionProvider
|
public class ApiDescriptionGroupCollectionProvider : IApiDescriptionGroupCollectionProvider
|
||||||
{
|
{
|
||||||
private readonly IActionDescriptorsCollectionProvider _actionDescriptorCollectionProvider;
|
private readonly IActionDescriptorCollectionProvider _actionDescriptorCollectionProvider;
|
||||||
private readonly IApiDescriptionProvider[] _apiDescriptionProviders;
|
private readonly IApiDescriptionProvider[] _apiDescriptionProviders;
|
||||||
|
|
||||||
private ApiDescriptionGroupCollection _apiDescriptionGroups;
|
private ApiDescriptionGroupCollection _apiDescriptionGroups;
|
||||||
|
|
@ -19,13 +19,13 @@ namespace Microsoft.AspNet.Mvc.ApiExplorer
|
||||||
/// Creates a new instance of <see cref="ApiDescriptionGroupCollectionProvider"/>.
|
/// Creates a new instance of <see cref="ApiDescriptionGroupCollectionProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="actionDescriptorCollectionProvider">
|
/// <param name="actionDescriptorCollectionProvider">
|
||||||
/// The <see cref="IActionDescriptorsCollectionProvider"/>.
|
/// The <see cref="IActionDescriptorCollectionProvider"/>.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="apiDescriptionProviders">
|
/// <param name="apiDescriptionProviders">
|
||||||
/// The <see cref="IEnumerable{IApiDescriptionProvider}}"/>.
|
/// The <see cref="IEnumerable{IApiDescriptionProvider}}"/>.
|
||||||
/// </param>
|
/// </param>
|
||||||
public ApiDescriptionGroupCollectionProvider(
|
public ApiDescriptionGroupCollectionProvider(
|
||||||
IActionDescriptorsCollectionProvider actionDescriptorCollectionProvider,
|
IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
|
||||||
IEnumerable<IApiDescriptionProvider> apiDescriptionProviders)
|
IEnumerable<IApiDescriptionProvider> apiDescriptionProviders)
|
||||||
{
|
{
|
||||||
_actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
|
_actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.ApiExplorer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiDescriptionGroupCollection GetCollection(ActionDescriptorsCollection actionDescriptors)
|
private ApiDescriptionGroupCollection GetCollection(ActionDescriptorCollection actionDescriptors)
|
||||||
{
|
{
|
||||||
var context = new ApiDescriptionProviderContext(actionDescriptors.Items);
|
var context = new ApiDescriptionProviderContext(actionDescriptors.Items);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
ServiceDescriptor.Transient<IApplicationModelProvider, DefaultApplicationModelProvider>());
|
ServiceDescriptor.Transient<IApplicationModelProvider, DefaultApplicationModelProvider>());
|
||||||
services.TryAddEnumerable(
|
services.TryAddEnumerable(
|
||||||
ServiceDescriptor.Transient<IActionDescriptorProvider, ControllerActionDescriptorProvider>());
|
ServiceDescriptor.Transient<IActionDescriptorProvider, ControllerActionDescriptorProvider>());
|
||||||
services.TryAddSingleton<IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>();
|
services.TryAddSingleton<IActionDescriptorCollectionProvider, DefaultActionDescriptorCollectionProvider>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Action Selection
|
// Action Selection
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A cached collection of <see cref="ActionDescriptor" />.
|
/// A cached collection of <see cref="ActionDescriptor" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActionDescriptorsCollection
|
public class ActionDescriptorCollection
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ActionDescriptorsCollection"/>.
|
/// Initializes a new instance of the <see cref="ActionDescriptorCollection"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="items">The result of action discovery</param>
|
/// <param name="items">The result of action discovery</param>
|
||||||
/// <param name="version">The unique version of discovered actions.</param>
|
/// <param name="version">The unique version of discovered actions.</param>
|
||||||
public ActionDescriptorsCollection(IReadOnlyList<ActionDescriptor> items, int version)
|
public ActionDescriptorCollection(IReadOnlyList<ActionDescriptor> items, int version)
|
||||||
{
|
{
|
||||||
if (items == null)
|
if (items == null)
|
||||||
{
|
{
|
||||||
|
|
@ -10,19 +10,19 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
namespace Microsoft.AspNet.Mvc.Infrastructure
|
namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default implementation for ActionDescriptors.
|
/// Default implementation of <see cref="IActionDescriptorCollectionProvider"/>.
|
||||||
/// This implementation caches the results at first call, and is not responsible for updates.
|
/// This implementation caches the results at first call, and is not responsible for updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DefaultActionDescriptorsCollectionProvider : IActionDescriptorsCollectionProvider
|
public class DefaultActionDescriptorCollectionProvider : IActionDescriptorCollectionProvider
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
private ActionDescriptorsCollection _collection;
|
private ActionDescriptorCollection _collection;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DefaultActionDescriptorsCollectionProvider" /> class.
|
/// Initializes a new instance of the <see cref="DefaultActionDescriptorCollectionProvider" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serviceProvider">The application IServiceProvider.</param>
|
/// <param name="serviceProvider">The application IServiceProvider.</param>
|
||||||
public DefaultActionDescriptorsCollectionProvider(IServiceProvider serviceProvider)
|
public DefaultActionDescriptorCollectionProvider(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a cached collection of <see cref="ActionDescriptor" />.
|
/// Returns a cached collection of <see cref="ActionDescriptor" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ActionDescriptorsCollection ActionDescriptors
|
public ActionDescriptorCollection ActionDescriptors
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionDescriptorsCollection GetCollection()
|
private ActionDescriptorCollection GetCollection()
|
||||||
{
|
{
|
||||||
var providers =
|
var providers =
|
||||||
_serviceProvider.GetServices<IActionDescriptorProvider>()
|
_serviceProvider.GetServices<IActionDescriptorProvider>()
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
providers[i].OnProvidersExecuted(context);
|
providers[i].OnProvidersExecuted(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ActionDescriptorsCollection(
|
return new ActionDescriptorCollection(
|
||||||
new ReadOnlyCollection<ActionDescriptor>(context.Results), 0);
|
new ReadOnlyCollection<ActionDescriptor>(context.Results), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,16 +10,16 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
/// The default implementation, does not update the cache, it is up to the user
|
/// The default implementation, does not update the cache, it is up to the user
|
||||||
/// to create or use an implementation that can update the available actions in
|
/// to create or use an implementation that can update the available actions in
|
||||||
/// the application. The implementor is also responsible for updating the
|
/// the application. The implementor is also responsible for updating the
|
||||||
/// <see cref="ActionDescriptorsCollection.Version"/> in a thread safe way.
|
/// <see cref="ActionDescriptorCollection.Version"/> in a thread safe way.
|
||||||
///
|
///
|
||||||
/// Default consumers of this service, are aware of the version and will recache
|
/// Default consumers of this service, are aware of the version and will recache
|
||||||
/// data as appropriate, but rely on the version being unique.
|
/// data as appropriate, but rely on the version being unique.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public interface IActionDescriptorsCollectionProvider
|
public interface IActionDescriptorCollectionProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the current cached <see cref="ActionDescriptorsCollection"/>
|
/// Returns the current cached <see cref="ActionDescriptorCollection"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ActionDescriptorsCollection ActionDescriptors { get; }
|
ActionDescriptorCollection ActionDescriptors { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
#if NET451
|
#if NET451
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
#endif
|
#endif
|
||||||
using System.Diagnostics;
|
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
|
@ -22,8 +21,8 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="ActionSelectionDecisionTree"/>.
|
/// Creates a new <see cref="ActionSelectionDecisionTree"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="actions">The <see cref="ActionDescriptorsCollection"/>.</param>
|
/// <param name="actions">The <see cref="ActionDescriptorCollection"/>.</param>
|
||||||
public ActionSelectionDecisionTree(ActionDescriptorsCollection actions)
|
public ActionSelectionDecisionTree(ActionDescriptorCollection actions)
|
||||||
{
|
{
|
||||||
Version = actions.Version;
|
Version = actions.Version;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,19 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public class ActionSelectorDecisionTreeProvider : IActionSelectorDecisionTreeProvider
|
public class ActionSelectorDecisionTreeProvider : IActionSelectorDecisionTreeProvider
|
||||||
{
|
{
|
||||||
private readonly IActionDescriptorsCollectionProvider _actionDescriptorsCollectionProvider;
|
private readonly IActionDescriptorCollectionProvider _actionDescriptorCollectionProvider;
|
||||||
private ActionSelectionDecisionTree _decisionTree;
|
private ActionSelectionDecisionTree _decisionTree;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="ActionSelectorDecisionTreeProvider"/>.
|
/// Creates a new <see cref="ActionSelectorDecisionTreeProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="actionDescriptorsCollectionProvider">
|
/// <param name="actionDescriptorCollectionProvider">
|
||||||
/// The <see cref="IActionDescriptorsCollectionProvider"/>.
|
/// The <see cref="IActionDescriptorCollectionProvider"/>.
|
||||||
/// </param>
|
/// </param>
|
||||||
public ActionSelectorDecisionTreeProvider(
|
public ActionSelectorDecisionTreeProvider(
|
||||||
IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider)
|
IActionDescriptorCollectionProvider actionDescriptorCollectionProvider)
|
||||||
{
|
{
|
||||||
_actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
|
_actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
@ -30,13 +30,13 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var descriptors = _actionDescriptorsCollectionProvider.ActionDescriptors;
|
var descriptors = _actionDescriptorCollectionProvider.ActionDescriptors;
|
||||||
if (descriptors == null)
|
if (descriptors == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
Resources.FormatPropertyOfTypeCannotBeNull(
|
Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
"ActionDescriptors",
|
"ActionDescriptors",
|
||||||
_actionDescriptorsCollectionProvider.GetType()));
|
_actionDescriptorCollectionProvider.GetType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_decisionTree == null || descriptors.Version != _decisionTree.Version)
|
if (_decisionTree == null || descriptors.Version != _decisionTree.Version)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
public class AttributeRoute : IRouter
|
public class AttributeRoute : IRouter
|
||||||
{
|
{
|
||||||
private readonly IRouter _target;
|
private readonly IRouter _target;
|
||||||
private readonly IActionDescriptorsCollectionProvider _actionDescriptorsCollectionProvider;
|
private readonly IActionDescriptorCollectionProvider _actionDescriptorCollectionProvider;
|
||||||
private readonly IInlineConstraintResolver _constraintResolver;
|
private readonly IInlineConstraintResolver _constraintResolver;
|
||||||
private readonly ObjectPool<UriBuildingContext> _contextPool;
|
private readonly ObjectPool<UriBuildingContext> _contextPool;
|
||||||
private readonly UrlEncoder _urlEncoder;
|
private readonly UrlEncoder _urlEncoder;
|
||||||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
|
|
||||||
public AttributeRoute(
|
public AttributeRoute(
|
||||||
IRouter target,
|
IRouter target,
|
||||||
IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider,
|
IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
|
||||||
IInlineConstraintResolver constraintResolver,
|
IInlineConstraintResolver constraintResolver,
|
||||||
ObjectPool<UriBuildingContext> contextPool,
|
ObjectPool<UriBuildingContext> contextPool,
|
||||||
UrlEncoder urlEncoder,
|
UrlEncoder urlEncoder,
|
||||||
|
|
@ -42,9 +42,9 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
throw new ArgumentNullException(nameof(target));
|
throw new ArgumentNullException(nameof(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionDescriptorsCollectionProvider == null)
|
if (actionDescriptorCollectionProvider == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(actionDescriptorsCollectionProvider));
|
throw new ArgumentNullException(nameof(actionDescriptorCollectionProvider));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constraintResolver == null)
|
if (constraintResolver == null)
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
}
|
}
|
||||||
|
|
||||||
_target = target;
|
_target = target;
|
||||||
_actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
|
_actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
|
||||||
_constraintResolver = constraintResolver;
|
_constraintResolver = constraintResolver;
|
||||||
_contextPool = contextPool;
|
_contextPool = contextPool;
|
||||||
_urlEncoder = urlEncoder;
|
_urlEncoder = urlEncoder;
|
||||||
|
|
@ -91,7 +91,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
|
|
||||||
private TreeRouter GetTreeRouter()
|
private TreeRouter GetTreeRouter()
|
||||||
{
|
{
|
||||||
var actions = _actionDescriptorsCollectionProvider.ActionDescriptors;
|
var actions = _actionDescriptorCollectionProvider.ActionDescriptors;
|
||||||
|
|
||||||
// This is a safe-race. We'll never set router back to null after initializing
|
// This is a safe-race. We'll never set router back to null after initializing
|
||||||
// it on startup.
|
// it on startup.
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
return _router;
|
return _router;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeRouter BuildRoute(ActionDescriptorsCollection actions)
|
private TreeRouter BuildRoute(ActionDescriptorCollection actions)
|
||||||
{
|
{
|
||||||
var routeBuilder = new TreeRouteBuilder(_target, _loggerFactory);
|
var routeBuilder = new TreeRouteBuilder(_target, _loggerFactory);
|
||||||
var routeInfos = GetRouteInfos(_constraintResolver, actions.Items);
|
var routeInfos = GetRouteInfos(_constraintResolver, actions.Items);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
throw new ArgumentNullException(nameof(services));
|
throw new ArgumentNullException(nameof(services));
|
||||||
}
|
}
|
||||||
|
|
||||||
var actionDescriptorProvider = services.GetRequiredService<IActionDescriptorsCollectionProvider>();
|
var actionDescriptorProvider = services.GetRequiredService<IActionDescriptorCollectionProvider>();
|
||||||
var inlineConstraintResolver = services.GetRequiredService<IInlineConstraintResolver>();
|
var inlineConstraintResolver = services.GetRequiredService<IInlineConstraintResolver>();
|
||||||
var pool = services.GetRequiredService<ObjectPool<UriBuildingContext>>();
|
var pool = services.GetRequiredService<ObjectPool<UriBuildingContext>>();
|
||||||
var urlEncoder = services.GetRequiredService<UrlEncoder>();
|
var urlEncoder = services.GetRequiredService<UrlEncoder>();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the version. The same as the value of
|
/// Gets the version. The same as the value of
|
||||||
/// <see cref="Infrastructure.ActionDescriptorsCollection.Version"/>.
|
/// <see cref="Infrastructure.ActionDescriptorCollection.Version"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int Version { get; }
|
int Version { get; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores an <see cref="ActionSelectionDecisionTree"/> for the current value of
|
/// Stores an <see cref="ActionSelectionDecisionTree"/> for the current value of
|
||||||
/// <see cref="Infrastructure.IActionDescriptorsCollectionProvider.ActionDescriptors"/>.
|
/// <see cref="Infrastructure.IActionDescriptorCollectionProvider.ActionDescriptors"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IActionSelectorDecisionTreeProvider
|
public interface IActionSelectorDecisionTreeProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="Infrastructure.IActionDescriptorsCollectionProvider"/>.
|
/// Gets the <see cref="Infrastructure.IActionDescriptorCollectionProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IActionSelectionDecisionTree DecisionTree
|
IActionSelectionDecisionTree DecisionTree
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,23 +64,23 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
|
|
||||||
private string[] GetAndCacheAllMatchingValues(string routeKey, HttpContext httpContext)
|
private string[] GetAndCacheAllMatchingValues(string routeKey, HttpContext httpContext)
|
||||||
{
|
{
|
||||||
var actionDescriptors = GetAndValidateActionDescriptorsCollection(httpContext);
|
var actionDescriptors = GetAndValidateActionDescriptorCollection(httpContext);
|
||||||
var version = actionDescriptors.Version;
|
var version = actionDescriptors.Version;
|
||||||
var valuesCollection = _cachedValuesCollection;
|
var valuesCollection = _cachedValuesCollection;
|
||||||
|
|
||||||
if (valuesCollection == null ||
|
if (valuesCollection == null ||
|
||||||
version != valuesCollection.Version)
|
version != valuesCollection.Version)
|
||||||
{
|
{
|
||||||
var routeValueCollection = actionDescriptors
|
var routeValueCollection =
|
||||||
.Items
|
actionDescriptors
|
||||||
.Select(ad => ad.RouteConstraints
|
.Items
|
||||||
.FirstOrDefault(
|
.Select(ad => ad.RouteConstraints.FirstOrDefault(
|
||||||
c => c.RouteKey == routeKey &&
|
c => c.RouteKey == routeKey &&
|
||||||
c.KeyHandling == RouteKeyHandling.RequireKey))
|
c.KeyHandling == RouteKeyHandling.RequireKey))
|
||||||
.Where(rc => rc != null)
|
.Where(rc => rc != null)
|
||||||
.Select(rc => rc.RouteValue)
|
.Select(rc => rc.RouteValue)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
valuesCollection = new RouteValuesCollection(version, routeValueCollection);
|
valuesCollection = new RouteValuesCollection(version, routeValueCollection);
|
||||||
_cachedValuesCollection = valuesCollection;
|
_cachedValuesCollection = valuesCollection;
|
||||||
|
|
@ -89,10 +89,10 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
return _cachedValuesCollection.Items;
|
return _cachedValuesCollection.Items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ActionDescriptorsCollection GetAndValidateActionDescriptorsCollection(HttpContext httpContext)
|
private static ActionDescriptorCollection GetAndValidateActionDescriptorCollection(HttpContext httpContext)
|
||||||
{
|
{
|
||||||
var provider = httpContext.RequestServices
|
var services = httpContext.RequestServices;
|
||||||
.GetRequiredService<IActionDescriptorsCollectionProvider>();
|
var provider = services.GetRequiredService<IActionDescriptorCollectionProvider>();
|
||||||
var descriptors = provider.ActionDescriptors;
|
var descriptors = provider.ActionDescriptors;
|
||||||
|
|
||||||
if (descriptors == null)
|
if (descriptors == null)
|
||||||
|
|
|
||||||
|
|
@ -518,9 +518,9 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
|
|
||||||
serviceContainer.AddSingleton(typeof(IEnumerable<IActionDescriptorProvider>), list);
|
serviceContainer.AddSingleton(typeof(IEnumerable<IActionDescriptorProvider>), list);
|
||||||
|
|
||||||
var actionDescriptorsCollectionProvider = new DefaultActionDescriptorsCollectionProvider(
|
var actionDescriptorCollectionProvider = new DefaultActionDescriptorCollectionProvider(
|
||||||
serviceContainer.BuildServiceProvider());
|
serviceContainer.BuildServiceProvider());
|
||||||
var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionDescriptorsCollectionProvider);
|
var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionDescriptorCollectionProvider);
|
||||||
|
|
||||||
var actionConstraintProviders = new[]
|
var actionConstraintProviders = new[]
|
||||||
{
|
{
|
||||||
|
|
@ -599,10 +599,10 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
|
||||||
{
|
{
|
||||||
loggerFactory = loggerFactory ?? NullLoggerFactory.Instance;
|
loggerFactory = loggerFactory ?? NullLoggerFactory.Instance;
|
||||||
|
|
||||||
var actionProvider = new Mock<IActionDescriptorsCollectionProvider>(MockBehavior.Strict);
|
var actionProvider = new Mock<IActionDescriptorCollectionProvider>(MockBehavior.Strict);
|
||||||
|
|
||||||
actionProvider
|
actionProvider
|
||||||
.Setup(p => p.ActionDescriptors).Returns(new ActionDescriptorsCollection(actions, 0));
|
.Setup(p => p.ActionDescriptors).Returns(new ActionDescriptorCollection(actions, 0));
|
||||||
|
|
||||||
var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionProvider.Object);
|
var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionProvider.Object);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,17 +64,17 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var actionDescriptorsProvider = new Mock<IActionDescriptorsCollectionProvider>(MockBehavior.Strict);
|
var actionDescriptorProvider = new Mock<IActionDescriptorCollectionProvider>(MockBehavior.Strict);
|
||||||
actionDescriptorsProvider
|
actionDescriptorProvider
|
||||||
.SetupGet(ad => ad.ActionDescriptors)
|
.SetupGet(ad => ad.ActionDescriptors)
|
||||||
.Returns(new ActionDescriptorsCollection(actionDescriptors, version: 1));
|
.Returns(new ActionDescriptorCollection(actionDescriptors, version: 1));
|
||||||
|
|
||||||
var policy = new UriBuilderContextPooledObjectPolicy(new UrlTestEncoder());
|
var policy = new UriBuilderContextPooledObjectPolicy(new UrlTestEncoder());
|
||||||
var pool = new DefaultObjectPool<UriBuildingContext>(policy);
|
var pool = new DefaultObjectPool<UriBuildingContext>(policy);
|
||||||
|
|
||||||
var route = new AttributeRoute(
|
var route = new AttributeRoute(
|
||||||
handler.Object,
|
handler.Object,
|
||||||
actionDescriptorsProvider.Object,
|
actionDescriptorProvider.Object,
|
||||||
Mock.Of<IInlineConstraintResolver>(),
|
Mock.Of<IInlineConstraintResolver>(),
|
||||||
pool,
|
pool,
|
||||||
new UrlTestEncoder(),
|
new UrlTestEncoder(),
|
||||||
|
|
@ -103,9 +103,9 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
|
|
||||||
// Arrange 2 - remove the action and update the collection
|
// Arrange 2 - remove the action and update the collection
|
||||||
actionDescriptors.RemoveAt(1);
|
actionDescriptors.RemoveAt(1);
|
||||||
actionDescriptorsProvider
|
actionDescriptorProvider
|
||||||
.SetupGet(ad => ad.ActionDescriptors)
|
.SetupGet(ad => ad.ActionDescriptors)
|
||||||
.Returns(new ActionDescriptorsCollection(actionDescriptors, version: 2));
|
.Returns(new ActionDescriptorCollection(actionDescriptors, version: 2));
|
||||||
|
|
||||||
context = new RouteContext(httpContext);
|
context = new RouteContext(httpContext);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,9 +180,9 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
|
|
||||||
private static IServiceProvider CreateServices(params ActionDescriptor[] actions)
|
private static IServiceProvider CreateServices(params ActionDescriptor[] actions)
|
||||||
{
|
{
|
||||||
var collection = new ActionDescriptorsCollection(actions, version: 0);
|
var collection = new ActionDescriptorCollection(actions, version: 0);
|
||||||
|
|
||||||
var actionDescriptorProvider = new Mock<IActionDescriptorsCollectionProvider>();
|
var actionDescriptorProvider = new Mock<IActionDescriptorCollectionProvider>();
|
||||||
actionDescriptorProvider
|
actionDescriptorProvider
|
||||||
.Setup(a => a.ActionDescriptors)
|
.Setup(a => a.ActionDescriptors)
|
||||||
.Returns(collection);
|
.Returns(collection);
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,13 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(RouteDirection.IncomingRequest)]
|
[InlineData(RouteDirection.IncomingRequest)]
|
||||||
[InlineData(RouteDirection.UrlGeneration)]
|
[InlineData(RouteDirection.UrlGeneration)]
|
||||||
public void ActionDescriptorsCollection_SettingNullValue_Throws(RouteDirection direction)
|
public void ActionDescriptorCollection_SettingNullValue_Throws(RouteDirection direction)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var actionDescriptorCollectionProvider = Mock.Of<IActionDescriptorsCollectionProvider>();
|
var actionDescriptorCollectionProvider = Mock.Of<IActionDescriptorCollectionProvider>();
|
||||||
var httpContext = new Mock<HttpContext>();
|
var httpContext = new Mock<HttpContext>();
|
||||||
httpContext
|
httpContext
|
||||||
.Setup(o => o.RequestServices.GetService(typeof(IActionDescriptorsCollectionProvider)))
|
.Setup(o => o.RequestServices.GetService(typeof(IActionDescriptorCollectionProvider)))
|
||||||
.Returns(actionDescriptorCollectionProvider);
|
.Returns(actionDescriptorCollectionProvider);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -175,8 +175,8 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
.Returns(new[] { actionProvider.Object });
|
.Returns(new[] { actionProvider.Object });
|
||||||
|
|
||||||
context.Setup(o => o.RequestServices
|
context.Setup(o => o.RequestServices
|
||||||
.GetService(typeof(IActionDescriptorsCollectionProvider)))
|
.GetService(typeof(IActionDescriptorCollectionProvider)))
|
||||||
.Returns(new DefaultActionDescriptorsCollectionProvider(context.Object.RequestServices));
|
.Returns(new DefaultActionDescriptorCollectionProvider(context.Object.RequestServices));
|
||||||
return context.Object;
|
return context.Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue