This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
/
ModelExpression.cs
67 lines (59 loc) · 2.49 KB
/
ModelExpression.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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 Microsoft.AspNetCore.Mvc.ModelBinding;
namespace Microsoft.AspNetCore.Mvc.ViewFeatures
{
/// <summary>
/// Describes an <see cref="System.Linq.Expressions.Expression"/> passed to a tag helper.
/// </summary>
public sealed class ModelExpression
{
/// <summary>
/// Initializes a new instance of the <see cref="ModelExpression"/> class.
/// </summary>
/// <param name="name">
/// String representation of the <see cref="System.Linq.Expressions.Expression"/> of interest.
/// </param>
/// <param name="modelExplorer">
/// Includes the model and metadata about the <see cref="System.Linq.Expressions.Expression"/> of interest.
/// </param>
public ModelExpression(string name, ModelExplorer modelExplorer)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (modelExplorer == null)
{
throw new ArgumentNullException(nameof(modelExplorer));
}
Name = name;
ModelExplorer = modelExplorer;
}
/// <summary>
/// String representation of the <see cref="System.Linq.Expressions.Expression"/> of interest.
/// </summary>
public string Name { get; }
/// <summary>
/// Metadata about the <see cref="System.Linq.Expressions.Expression"/> of interest.
/// </summary>
public ModelMetadata Metadata => ModelExplorer.Metadata;
/// <summary>
/// Gets the model object for the <see cref="System.Linq.Expressions.Expression"/> of interest.
/// </summary>
/// <remarks>
/// Getting <see cref="Model"/> will evaluate a compiled version of the original
/// <see cref="System.Linq.Expressions.Expression"/>.
/// </remarks>
public object Model => ModelExplorer.Model;
/// <summary>
/// Gets the model explorer for the <see cref="System.Linq.Expressions.Expression"/> of interest.
/// </summary>
/// <remarks>
/// Getting <see cref="ModelExplorer.Model"/> will evaluate a compiled version of the original
/// <see cref="System.Linq.Expressions.Expression"/>.
/// </remarks>
public ModelExplorer ModelExplorer { get; }
}
}