11/*
2- * Copyright (c) 2015, Facebook, Inc.
2+ * Copyright (c) 2014- 2015, Facebook, Inc.
33 * All rights reserved.
44 *
55 * This source code is licensed under the BSD-style license found in the
66 * LICENSE file in the root directory of this source tree. An additional grant
77 * of patent rights can be found in the PATENTS file in the same directory.
88 */
9-
9+
10+ #if LEGACYASPNET
11+ using System . Web ;
12+ using System . Web . Mvc ;
13+ using IHtmlHelper = System . Web . Mvc . HtmlHelper ;
14+ #else
1015using Microsoft . AspNet . Mvc . Rendering ;
16+ using IHtmlString = Microsoft . AspNet . Mvc . Rendering . HtmlString ;
17+ #endif
1118
19+ #if LEGACYASPNET
20+ namespace React . Web . Mvc
21+ #else
1222namespace React . AspNet
23+ #endif
1324{
1425 /// <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.
1627 /// </summary>
1728 public static class HtmlHelperExtensions
18- {
19- // TODO: Figure out if this can be injected
29+ {
30+
2031 /// <summary>
2132 /// Gets the React environment
2233 /// </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+ }
2539
2640 /// <summary>
2741 /// Renders the specified React component
@@ -33,7 +47,7 @@ public static class HtmlHelperExtensions
3347 /// <param name="htmlTag">HTML tag to wrap the component in. Defaults to <div></param>
3448 /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
3549 /// <returns>The component's HTML</returns>
36- public static HtmlString React < T > (
50+ public static IHtmlString React < T > (
3751 this IHtmlHelper htmlHelper ,
3852 string componentName ,
3953 T props ,
@@ -62,7 +76,7 @@ public static HtmlString React<T>(
6276 /// <param name="htmlTag">HTML tag to wrap the component in. Defaults to <div></param>
6377 /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
6478 /// <returns>The component's HTML</returns>
65- public static HtmlString ReactWithInit < T > (
79+ public static IHtmlString ReactWithInit < T > (
6680 this IHtmlHelper htmlHelper ,
6781 string componentName ,
6882 T props ,
@@ -88,7 +102,7 @@ public static HtmlString ReactWithInit<T>(
88102 /// attach event handlers to the server-rendered HTML.
89103 /// </summary>
90104 /// <returns>JavaScript for all components</returns>
91- public static HtmlString ReactInitJavaScript ( this IHtmlHelper htmlHelper )
105+ public static IHtmlString ReactInitJavaScript ( this IHtmlHelper htmlHelper )
92106 {
93107 var script = Environment . GetInitJavaScript ( ) ;
94108 var tag = new TagBuilder ( "script" )
0 commit comments