New test.
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / Html / DisplayExtensions.cs
1 /* ****************************************************************************\r
2  *\r
3  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4  *\r
5  * This software is subject to the Microsoft Public License (Ms-PL). \r
6  * A copy of the license can be found in the license.htm file included \r
7  * in this distribution.\r
8  *\r
9  * You must not remove this notice, or any other, from this software.\r
10  *\r
11  * ***************************************************************************/\r
12 \r
13 namespace System.Web.Mvc.Html {\r
14     using System.Linq.Expressions;\r
15     using System.Web.UI.WebControls;\r
16 \r
17     public static class DisplayExtensions {\r
18         public static MvcHtmlString Display(this HtmlHelper html, string expression) {\r
19             return TemplateHelpers.Template(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
20         }\r
21 \r
22         public static MvcHtmlString Display(this HtmlHelper html, string expression, object additionalViewData) {\r
23             return TemplateHelpers.Template(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
24         }\r
25 \r
26         public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName) {\r
27             return TemplateHelpers.Template(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
28         }\r
29 \r
30         public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName, object additionalViewData) {\r
31             return TemplateHelpers.Template(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
32         }\r
33 \r
34         public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName, string htmlFieldName) {\r
35             return TemplateHelpers.Template(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
36         }\r
37 \r
38         public static MvcHtmlString Display(this HtmlHelper html, string expression, string templateName, string htmlFieldName, object additionalViewData) {\r
39             return TemplateHelpers.Template(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, additionalViewData);\r
40         }\r
41 \r
42         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
43             Justification = "This is an appropriate nesting of generic types")]\r
44         public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression) {\r
45             return TemplateHelpers.TemplateFor(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
46         }\r
47 \r
48         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
49             Justification = "This is an appropriate nesting of generic types")]\r
50         public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object additionalViewData) {\r
51             return TemplateHelpers.TemplateFor(html, expression, null /* templateName */, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
52         }\r
53 \r
54         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
55             Justification = "This is an appropriate nesting of generic types")]\r
56         public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName) {\r
57             return TemplateHelpers.TemplateFor(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
58         }\r
59 \r
60         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
61             Justification = "This is an appropriate nesting of generic types")]\r
62         public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, object additionalViewData) {\r
63             return TemplateHelpers.TemplateFor(html, expression, templateName, null /* htmlFieldName */, DataBoundControlMode.ReadOnly, additionalViewData);\r
64         }\r
65 \r
66         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
67             Justification = "This is an appropriate nesting of generic types")]\r
68         public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName) {\r
69             return TemplateHelpers.TemplateFor(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, null /* additionalViewData */);\r
70         }\r
71 \r
72         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",\r
73             Justification = "This is an appropriate nesting of generic types")]\r
74         public static MvcHtmlString DisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName, object additionalViewData) {\r
75             return TemplateHelpers.TemplateFor(html, expression, templateName, htmlFieldName, DataBoundControlMode.ReadOnly, additionalViewData);\r
76         }\r
77 \r
78         public static MvcHtmlString DisplayForModel(this HtmlHelper html) {\r
79             return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, null /* templateName */, DataBoundControlMode.ReadOnly, null /* additionalViewData */));\r
80         }\r
81 \r
82         public static MvcHtmlString DisplayForModel(this HtmlHelper html, object additionalViewData) {\r
83             return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, null /* templateName */, DataBoundControlMode.ReadOnly, additionalViewData));\r
84         }\r
85 \r
86         public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName) {\r
87             return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, templateName, DataBoundControlMode.ReadOnly, null /* additionalViewData */));\r
88         }\r
89 \r
90         public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName, object additionalViewData) {\r
91             return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, String.Empty, templateName, DataBoundControlMode.ReadOnly,   additionalViewData ));\r
92         }\r
93 \r
94         public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName, string htmlFieldName) {\r
95             return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, htmlFieldName, templateName, DataBoundControlMode.ReadOnly, null /* additionalViewData */));\r
96         }\r
97 \r
98         public static MvcHtmlString DisplayForModel(this HtmlHelper html, string templateName, string htmlFieldName, object additionalViewData) {\r
99             return MvcHtmlString.Create(TemplateHelpers.TemplateHelper(html, html.ViewData.ModelMetadata, htmlFieldName, templateName, DataBoundControlMode.ReadOnly, additionalViewData));\r
100         }\r
101     }\r
102 }\r