forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplayTextExtensions.cs
More file actions
29 lines (23 loc) · 845 Bytes
/
Copy pathDisplayTextExtensions.cs
File metadata and controls
29 lines (23 loc) · 845 Bytes
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
#if !NETSTANDARD2_0
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Linq.Expressions;
namespace ServiceStack.Html
{
public static class DisplayTextExtensions
{
public static MvcHtmlString DisplayText(this HtmlHelper html, string name)
{
return DisplayTextHelper(ModelMetadata.FromStringExpression(name, html.ViewData));
}
public static MvcHtmlString DisplayTextFor<TModel, TResult>(this HtmlHelper<TModel> html, Expression<Func<TModel, TResult>> expression)
{
return DisplayTextHelper(ModelMetadata.FromLambdaExpression(expression, html.ViewData));
}
private static MvcHtmlString DisplayTextHelper(ModelMetadata metadata)
{
return MvcHtmlString.Create(metadata.SimpleDisplayText);
}
}
}
#endif