1
1
/*
2
- * Copyright (c) 2015, Facebook, Inc.
2
+ * Copyright (c) 2014- 2015, Facebook, Inc.
3
3
* All rights reserved.
4
4
*
5
5
* This source code is licensed under the BSD-style license found in the
6
6
* LICENSE file in the root directory of this source tree. An additional grant
7
7
* of patent rights can be found in the PATENTS file in the same directory.
8
8
*/
9
-
9
+
10
+ #if LEGACYASPNET
11
+ using System . Web ;
12
+ using System . Web . Mvc ;
13
+ using IHtmlHelper = System . Web . Mvc . HtmlHelper ;
14
+ #else
10
15
using Microsoft . AspNet . Mvc . Rendering ;
16
+ using IHtmlString = Microsoft . AspNet . Mvc . Rendering . HtmlString ;
17
+ #endif
11
18
19
+ #if LEGACYASPNET
20
+ namespace React . Web . Mvc
21
+ #else
12
22
namespace React . AspNet
23
+ #endif
13
24
{
14
25
/// <summary>
15
- /// HTML Helpers for utilising React from an ASP.NET MVC 6 (vNext) application.
26
+ /// HTML Helpers for utilising React from an ASP.NET MVC application.
16
27
/// </summary>
17
28
public static class HtmlHelperExtensions
18
- {
19
- // TODO: Figure out if this can be injected
29
+ {
30
+
20
31
/// <summary>
21
32
/// Gets the React environment
22
33
/// </summary>
23
- private static IReactEnvironment Environment =>
24
- global ::React . AssemblyRegistration . Container . Resolve < IReactEnvironment > ( ) ;
34
+ private static IReactEnvironment Environment
35
+ {
36
+ // TODO: Figure out if this can be injected
37
+ get { return global ::React . AssemblyRegistration . Container . Resolve < IReactEnvironment > ( ) ; }
38
+ }
25
39
26
40
/// <summary>
27
41
/// Renders the specified React component
@@ -33,7 +47,7 @@ public static class HtmlHelperExtensions
33
47
/// <param name="htmlTag">HTML tag to wrap the component in. Defaults to <div></param>
34
48
/// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
35
49
/// <returns>The component's HTML</returns>
36
- public static HtmlString React < T > (
50
+ public static IHtmlString React < T > (
37
51
this IHtmlHelper htmlHelper ,
38
52
string componentName ,
39
53
T props ,
@@ -62,7 +76,7 @@ public static HtmlString React<T>(
62
76
/// <param name="htmlTag">HTML tag to wrap the component in. Defaults to <div></param>
63
77
/// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
64
78
/// <returns>The component's HTML</returns>
65
- public static HtmlString ReactWithInit < T > (
79
+ public static IHtmlString ReactWithInit < T > (
66
80
this IHtmlHelper htmlHelper ,
67
81
string componentName ,
68
82
T props ,
@@ -88,7 +102,7 @@ public static HtmlString ReactWithInit<T>(
88
102
/// attach event handlers to the server-rendered HTML.
89
103
/// </summary>
90
104
/// <returns>JavaScript for all components</returns>
91
- public static HtmlString ReactInitJavaScript ( this IHtmlHelper htmlHelper )
105
+ public static IHtmlString ReactInitJavaScript ( this IHtmlHelper htmlHelper )
92
106
{
93
107
var script = Environment . GetInitJavaScript ( ) ;
94
108
var tag = new TagBuilder ( "script" )
0 commit comments