Skip to content

Commit 763aba2

Browse files
committed
Attempted to create vNext version of react.web.mvc
1 parent 783b4e3 commit 763aba2

File tree

11 files changed

+235
-16
lines changed

11 files changed

+235
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,4 @@ UpgradeLog*.htm
184184

185185
# Microsoft Fakes
186186
FakesAssemblies/
187+
/src/React.sln.ide

src/React.Sample.Cassette/React.Sample.Cassette.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<IISExpressAnonymousAuthentication />
2121
<IISExpressWindowsAuthentication />
2222
<IISExpressUseClassicPipelineMode />
23+
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
24+
<FileUpgradeFlags>40</FileUpgradeFlags>
25+
<UpgradeBackupLocation>C:\Users\Luke\Dropbox\Documents\GitHub\React.NET\src\Backup3\</UpgradeBackupLocation>
26+
<OldToolsVersion>12.0</OldToolsVersion>
2327
</PropertyGroup>
2428
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2529
<DebugSymbols>true</DebugSymbols>

src/React.Sample.Mvc4/React.Sample.Mvc4.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<IISExpressWindowsAuthentication />
2222
<IISExpressUseClassicPipelineMode />
2323
<WebGreaseLibPath>..\packages\WebGrease.1.5.2\lib</WebGreaseLibPath>
24+
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
25+
<FileUpgradeFlags>40</FileUpgradeFlags>
26+
<UpgradeBackupLocation>C:\Users\Luke\Dropbox\Documents\GitHub\React.NET\src\Backup3\</UpgradeBackupLocation>
27+
<OldToolsVersion>12.0</OldToolsVersion>
2428
</PropertyGroup>
2529
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2630
<DebugSymbols>true</DebugSymbols>

src/React.Sample.Webpack/React.Sample.Webpack.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<IISExpressAnonymousAuthentication />
2121
<IISExpressWindowsAuthentication />
2222
<IISExpressUseClassicPipelineMode />
23+
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
24+
<FileUpgradeFlags>40</FileUpgradeFlags>
25+
<UpgradeBackupLocation>C:\Users\Luke\Dropbox\Documents\GitHub\React.NET\src\Backup3\</UpgradeBackupLocation>
26+
<OldToolsVersion>12.0</OldToolsVersion>
2327
</PropertyGroup>
2428
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2529
<DebugSymbols>true</DebugSymbols>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright (c) 2014-2015, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
using Microsoft.AspNet.Mvc;
11+
12+
namespace React.Web.Mvc
13+
{
14+
using Microsoft.AspNet.Mvc.Rendering;
15+
using AssemblyRegistration = React.AssemblyRegistration;
16+
17+
/// <summary>
18+
/// HTML Helpers for utilising React from an ASP.NET MVC application.
19+
/// </summary>
20+
public static class HtmlHelperExtensions
21+
{
22+
/// <summary>
23+
/// Gets the React environment
24+
/// </summary>
25+
private static IReactEnvironment Environment
26+
{
27+
// TODO: Figure out if this can be injected
28+
get { return AssemblyRegistration.Container.Resolve<IReactEnvironment>(); }
29+
}
30+
31+
/// <summary>
32+
/// Renders the specified React component
33+
/// </summary>
34+
/// <typeparam name="T">Type of the props</typeparam>
35+
/// <param name="htmlHelper">HTML helper</param>
36+
/// <param name="componentName">Name of the component</param>
37+
/// <param name="props">Props to initialise the component with</param>
38+
/// <param name="htmlTag">HTML tag to wrap the component in. Defaults to &lt;div&gt;</param>
39+
/// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
40+
/// <returns>The component's HTML</returns>
41+
public static HtmlString React<T>(
42+
this HtmlHelper htmlHelper,
43+
string componentName,
44+
T props,
45+
string htmlTag = null,
46+
string containerId = null
47+
)
48+
{
49+
var reactComponent = Environment.CreateComponent(componentName, props, containerId);
50+
if (!string.IsNullOrEmpty(htmlTag))
51+
{
52+
reactComponent.ContainerTag = htmlTag;
53+
}
54+
var result = reactComponent.RenderHtml();
55+
return new HtmlString(result);
56+
}
57+
58+
/// <summary>
59+
/// Renders the specified React component, along with its client-side initialisation code.
60+
/// Normally you would use the <see cref="React{T}"/> method, but <see cref="ReactWithInit{T}"/>
61+
/// is useful when rendering self-contained partial views.
62+
/// </summary>
63+
/// <typeparam name="T">Type of the props</typeparam>
64+
/// <param name="htmlHelper">HTML helper</param>
65+
/// <param name="componentName">Name of the component</param>
66+
/// <param name="props">Props to initialise the component with</param>
67+
/// <param name="htmlTag">HTML tag to wrap the component in. Defaults to &lt;div&gt;</param>
68+
/// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
69+
/// <returns>The component's HTML</returns>
70+
public static HtmlString ReactWithInit<T>(
71+
this HtmlHelper htmlHelper,
72+
string componentName,
73+
T props,
74+
string htmlTag = null,
75+
string containerId = null
76+
)
77+
{
78+
var reactComponent = Environment.CreateComponent(componentName, props, containerId);
79+
if (!string.IsNullOrEmpty(htmlTag))
80+
{
81+
reactComponent.ContainerTag = htmlTag;
82+
}
83+
var html = reactComponent.RenderHtml();
84+
var script = new TagBuilder("script")
85+
{
86+
InnerHtml = reactComponent.RenderJavaScript()
87+
};
88+
return new HtmlString(html + System.Environment.NewLine + script.ToString());
89+
}
90+
91+
/// <summary>
92+
/// Renders the JavaScript required to initialise all components client-side. This will
93+
/// attach event handlers to the server-rendered HTML.
94+
/// </summary>
95+
/// <returns>JavaScript for all components</returns>
96+
public static HtmlString ReactInitJavaScript(this HtmlHelper htmlHelper)
97+
{
98+
var script = Environment.GetInitJavaScript();
99+
var tag = new TagBuilder("script")
100+
{
101+
InnerHtml = script
102+
};
103+
return new HtmlString(tag.ToString());
104+
}
105+
}
106+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>f377cb55-24ea-43d4-92b1-172aa82dac7b</ProjectGuid>
10+
<RootNamespace>React.Web.Mvc6</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
13+
</PropertyGroup>
14+
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
15+
<AssemblyName>React.Web.Mvc6</AssemblyName>
16+
</PropertyGroup>
17+
<PropertyGroup>
18+
<SchemaVersion>2.0</SchemaVersion>
19+
</PropertyGroup>
20+
<ItemGroup>
21+
<ProjectReference Include="..\React.Web\React.Web.csproj" />
22+
<ProjectReference Include="..\React\React.csproj" />
23+
</ItemGroup>
24+
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
25+
<ProjectExtensions>
26+
<VisualStudio>
27+
<UserProperties project_1json__JSONSchema="http://www.asp.net/media/4878834/project.json" />
28+
</VisualStudio>
29+
</ProjectExtensions>
30+
</Project>

src/React.Web.Mvc6/project.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "1.0.0-*",
3+
"dependencies": {
4+
"Microsoft.AspNet.Mvc": "6.0.0.0-beta2"
5+
},
6+
"frameworks": {
7+
"aspnet50": {
8+
"dependencies": {
9+
"React": "",
10+
"React.Web": ""
11+
}
12+
},
13+
"aspnetcore50": {
14+
"dependencies": {
15+
"System.Runtime": "4.0.20-beta-22231"
16+
}
17+
}
18+
}
19+
}

src/React.sln

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.31101.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.22512.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Sample.Mvc4", "React.Sample.Mvc4\React.Sample.Mvc4.csproj", "{22796879-968A-4C26-9B4B-4C44792B36DB}"
7-
ProjectSection(ProjectDependencies) = postProject
8-
{AF531A37-B93F-4113-9C2C-4DB28064B926} = {AF531A37-B93F-4113-9C2C-4DB28064B926}
9-
EndProjectSection
10-
EndProject
116
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{F567B25C-E869-4C93-9C96-077761250F87}"
127
EndProject
138
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{A51CE5B6-294F-4D39-B32B-BF08DAF9B40B}"
149
EndProject
1510
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library", "Library", "{681C45FB-103C-48BC-B992-20C5B6B78F92}"
1611
EndProject
17-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React", "React\React.csproj", "{D0CC8A22-CEE6-485C-924B-1F94426FEA59}"
18-
EndProject
19-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Tests", "React.Tests\React.Tests.csproj", "{D7C645EB-7B85-45D5-AAA6-CAD3DE704381}"
20-
EndProject
2112
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{CB51F03F-49BD-4B79-8AD4-67962230E76B}"
2213
ProjectSection(SolutionItems) = preProject
2314
..\.gitignore = ..\.gitignore
2415
..\build.proj = ..\build.proj
2516
..\dev-build-push.bat = ..\dev-build-push.bat
2617
..\dev-build.bat = ..\dev-build.bat
18+
global.json = global.json
2719
..\README.md = ..\README.md
2820
..\release-build-push.bat = ..\release-build-push.bat
2921
..\release-build.bat = ..\release-build.bat
3022
SharedAssemblyInfo.cs = SharedAssemblyInfo.cs
3123
template.nuspec = template.nuspec
3224
EndProjectSection
25+
ProjectSection(FolderGlobals) = preProject
26+
src_2global_1json__JSONSchema = http://json.schemastore.org/global
27+
EndProjectSection
28+
EndProject
29+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F2875D3A-0C8A-439B-B734-ECABA00AC629}"
30+
ProjectSection(SolutionItems) = preProject
31+
.nuget\packages.config = .nuget\packages.config
32+
EndProjectSection
33+
EndProject
34+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Sample.Mvc4", "React.Sample.Mvc4\React.Sample.Mvc4.csproj", "{22796879-968A-4C26-9B4B-4C44792B36DB}"
35+
ProjectSection(ProjectDependencies) = postProject
36+
{AF531A37-B93F-4113-9C2C-4DB28064B926} = {AF531A37-B93F-4113-9C2C-4DB28064B926}
37+
EndProjectSection
38+
EndProject
39+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React", "React\React.csproj", "{D0CC8A22-CEE6-485C-924B-1F94426FEA59}"
40+
EndProject
41+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Tests", "React.Tests\React.Tests.csproj", "{D7C645EB-7B85-45D5-AAA6-CAD3DE704381}"
3342
EndProject
3443
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Web", "React.Web\React.Web.csproj", "{134EDD16-8DC8-4983-A2E0-B38DAB1ECF1C}"
3544
EndProject
@@ -45,11 +54,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Web.Mvc3", "React.Web
4554
EndProject
4655
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.MSBuild", "React.MSBuild\React.MSBuild.csproj", "{AF531A37-B93F-4113-9C2C-4DB28064B926}"
4756
EndProject
48-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F2875D3A-0C8A-439B-B734-ECABA00AC629}"
49-
ProjectSection(SolutionItems) = preProject
50-
.nuget\packages.config = .nuget\packages.config
51-
EndProjectSection
52-
EndProject
5357
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.JavaScriptEngine.VroomJs", "React.JavaScriptEngine.VroomJs\React.JavaScriptEngine.VroomJs.csproj", "{B4A5902A-70E2-4FA4-817D-DCC78D31E9B9}"
5458
EndProject
5559
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.JavaScriptEngine.ClearScriptV8", "React.JavaScriptEngine.ClearScriptV8\React.JavaScriptEngine.ClearScriptV8.csproj", "{7FBE07B3-C7BA-48DA-8B53-0DB0BB82DA09}"
@@ -60,6 +64,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Owin", "React.Owin\Re
6064
EndProject
6165
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "React.Sample.Webpack", "React.Sample.Webpack\React.Sample.Webpack.csproj", "{E20376AD-80F7-4865-ACE3-1DE616991DF7}"
6266
EndProject
67+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "React.Web.Mvc6", "React.Web.Mvc6\React.Web.Mvc6.kproj", "{F377CB55-24EA-43D4-92B1-172AA82DAC7B}"
68+
EndProject
6369
Global
6470
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6571
Debug|Any CPU = Debug|Any CPU
@@ -126,6 +132,10 @@ Global
126132
{E20376AD-80F7-4865-ACE3-1DE616991DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
127133
{E20376AD-80F7-4865-ACE3-1DE616991DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
128134
{E20376AD-80F7-4865-ACE3-1DE616991DF7}.Release|Any CPU.Build.0 = Release|Any CPU
135+
{F377CB55-24EA-43D4-92B1-172AA82DAC7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
136+
{F377CB55-24EA-43D4-92B1-172AA82DAC7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
137+
{F377CB55-24EA-43D4-92B1-172AA82DAC7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
138+
{F377CB55-24EA-43D4-92B1-172AA82DAC7B}.Release|Any CPU.Build.0 = Release|Any CPU
129139
EndGlobalSection
130140
GlobalSection(SolutionProperties) = preSolution
131141
HideSolutionNode = FALSE
@@ -146,5 +156,6 @@ Global
146156
{84C5EB9D-FB4E-44C3-91C4-2F2393C58B39} = {A51CE5B6-294F-4D39-B32B-BF08DAF9B40B}
147157
{C3BF8D49-B7CC-4D7F-B0F0-A94347C595EA} = {681C45FB-103C-48BC-B992-20C5B6B78F92}
148158
{E20376AD-80F7-4865-ACE3-1DE616991DF7} = {A51CE5B6-294F-4D39-B32B-BF08DAF9B40B}
159+
{F377CB55-24EA-43D4-92B1-172AA82DAC7B} = {681C45FB-103C-48BC-B992-20C5B6B78F92}
149160
EndGlobalSection
150161
EndGlobal

src/global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"sources": ["wrap"]
3+
}

src/wrap/React.Web/project.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "1.0.0-*",
3+
"frameworks": {
4+
"net40": {
5+
"wrappedProject": "../../React.Web/React.Web.csproj",
6+
"bin": {
7+
"assembly": "../../React.Web/obj/{configuration}/React.Web.dll",
8+
"pdb": "../../React.Web/obj/{configuration}/React.Web.pdb"
9+
},
10+
"dependencies": {
11+
"Microsoft.Web.Infrastructure": "1.0.0",
12+
"Newtonsoft.Json": "5.0.4",
13+
"WebActivatorEx": "2.0.5"
14+
}
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)