This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,013 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Microsoft.AspNetCore.Mvc.RazorPages/ApplicationModels/IPageRouteModelConvention.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 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. | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ApplicationModels | ||
{ | ||
/// <summary> | ||
/// Allows customization of the of the <see cref="PageRouteModel"/>. | ||
/// </summary> | ||
public interface IPageRouteModelConvention | ||
{ | ||
/// <summary> | ||
/// Called to apply the convention to the <see cref="PageRouteModel"/>. | ||
/// </summary> | ||
/// <param name="model">The <see cref="PageRouteModel"/>.</param> | ||
void Apply(PageRouteModel model); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Microsoft.AspNetCore.Mvc.RazorPages/ApplicationModels/IPageRouteModelProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// 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. | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ApplicationModels | ||
{ | ||
/// <summary> | ||
/// Builds or modifies an <see cref="PageRouteModelProviderContext"/> for Razor Page routing. | ||
/// </summary> | ||
public interface IPageRouteModelProvider | ||
{ | ||
/// <summary> | ||
/// Gets the order value for determining the order of execution of providers. Providers execute in | ||
/// ascending numeric value of the <see cref="Order"/> property. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// Providers are executed in an ordering determined by an ascending sort of the <see cref="Order"/> property. | ||
/// A provider with a lower numeric value of <see cref="Order"/> will have its | ||
/// <see cref="OnProvidersExecuting"/> called before that of a provider with a higher numeric value of | ||
/// <see cref="Order"/>. The <see cref="OnProvidersExecuted"/> method is called in the reverse ordering after | ||
/// all calls to <see cref="OnProvidersExecuting"/>. A provider with a lower numeric value of | ||
/// <see cref="Order"/> will have its <see cref="OnProvidersExecuted"/> method called after that of a provider | ||
/// with a higher numeric value of <see cref="Order"/>. | ||
/// </para> | ||
/// <para> | ||
/// If two providers have the same numeric value of <see cref="Order"/>, then their relative execution order | ||
/// is undefined. | ||
/// </para> | ||
/// </remarks> | ||
int Order { get; } | ||
|
||
/// <summary> | ||
/// Executed for the first pass of building <see cref="PageRouteModel"/> instances. See <see cref="Order"/>. | ||
/// </summary> | ||
/// <param name="context">The <see cref="PageRouteModelProviderContext"/>.</param> | ||
void OnProvidersExecuting(PageRouteModelProviderContext context); | ||
|
||
/// <summary> | ||
/// Executed for the second pass of building <see cref="PageRouteModel"/> instances. See <see cref="Order"/>. | ||
/// </summary> | ||
/// <param name="context">The <see cref="PageRouteModelProviderContext"/>.</param> | ||
void OnProvidersExecuted(PageRouteModelProviderContext context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Microsoft.AspNetCore.Mvc.RazorPages/ApplicationModels/PageHandlerModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Microsoft.AspNetCore.Mvc.Internal; | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ApplicationModels | ||
{ | ||
/// <summary> | ||
/// A type which is used to represent a property in a <see cref="PageApplicationModel"/>. | ||
/// </summary> | ||
[DebuggerDisplay("PageHandlerModel: Name={MethodName}")] | ||
public class PageHandlerModel : ICommonModel | ||
{ | ||
public PageHandlerModel( | ||
MethodInfo handlerMethod, | ||
IReadOnlyList<object> attributes) | ||
{ | ||
HandlerMethod = handlerMethod ?? throw new ArgumentNullException(nameof(handlerMethod)); | ||
|
||
Attributes = attributes; | ||
Parameters = new List<PageParameterModel>(); | ||
Properties = new Dictionary<object, object>(); | ||
} | ||
|
||
public PageHandlerModel(PageHandlerModel other) | ||
{ | ||
if (other == null) | ||
{ | ||
throw new ArgumentNullException(nameof(other)); | ||
} | ||
|
||
HandlerMethod = other.HandlerMethod; | ||
Name = other.Name; | ||
|
||
Page = other.Page; | ||
|
||
// These are just metadata, safe to create new collections | ||
Attributes = new List<object>(other.Attributes); | ||
Properties = new Dictionary<object, object>(other.Properties); | ||
|
||
// Make a deep copy of other 'model' types. | ||
Parameters = new List<PageParameterModel>(other.Parameters.Select(p => new PageParameterModel(p) { Handler = this })); | ||
} | ||
|
||
public MethodInfo HandlerMethod { get; } | ||
|
||
public string HttpMethod { get; set; } | ||
|
||
public string Name { get; set; } | ||
|
||
public IList<PageParameterModel> Parameters { get; } | ||
|
||
public PageApplicationModel Page { get; set; } | ||
|
||
public IReadOnlyList<object> Attributes { get; } | ||
|
||
MemberInfo ICommonModel.MemberInfo => HandlerMethod; | ||
|
||
public IDictionary<object, object> Properties { get; } | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/Microsoft.AspNetCore.Mvc.RazorPages/ApplicationModels/PageParameterModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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.Reflection; | ||
using Microsoft.AspNetCore.Mvc.ModelBinding; | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ApplicationModels | ||
{ | ||
[DebuggerDisplay("PageParameterModel: Name={ParameterName}")] | ||
public class PageParameterModel : ICommonModel, IBindingModel | ||
{ | ||
public PageParameterModel( | ||
ParameterInfo parameterInfo, | ||
IReadOnlyList<object> attributes) | ||
{ | ||
ParameterInfo = parameterInfo ?? throw new ArgumentNullException(nameof(parameterInfo)); | ||
|
||
if (attributes == null) | ||
{ | ||
throw new ArgumentNullException(nameof(attributes)); | ||
} | ||
|
||
Properties = new Dictionary<object, object>(); | ||
Attributes = new List<object>(attributes); | ||
} | ||
|
||
public PageParameterModel(PageParameterModel other) | ||
{ | ||
if (other == null) | ||
{ | ||
throw new ArgumentNullException(nameof(other)); | ||
} | ||
|
||
Handler = other.Handler; | ||
Attributes = new List<object>(other.Attributes); | ||
BindingInfo = other.BindingInfo == null ? null : new BindingInfo(other.BindingInfo); | ||
ParameterInfo = other.ParameterInfo; | ||
ParameterName = other.ParameterName; | ||
Properties = new Dictionary<object, object>(other.Properties); | ||
} | ||
|
||
public PageHandlerModel Handler { get; set; } | ||
|
||
public IReadOnlyList<object> Attributes { get; } | ||
|
||
public IDictionary<object, object> Properties { get; } | ||
|
||
MemberInfo ICommonModel.MemberInfo => ParameterInfo.Member; | ||
|
||
string ICommonModel.Name => ParameterName; | ||
|
||
public ParameterInfo ParameterInfo { get; } | ||
|
||
public string ParameterName { get; set; } | ||
|
||
public BindingInfo BindingInfo { get; set; } | ||
} | ||
} |
Oops, something went wrong.