Skip to content

Commit 33c2378

Browse files
committed
Added a sample ASP.NET Core 1.0 sites
1 parent 1bbf665 commit 33c2378

File tree

110 files changed

+5995
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+5995
-17
lines changed

JavaScriptEngineSwitcher.DotNet.sln

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0C281F46-F1D
1414
EndProject
1515
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{53B43213-2E66-42C2-8476-600A2FD2DA75}"
1616
EndProject
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E5989CB5-AACE-4D35-A8EE-26942F140DA3}"
18+
EndProject
1719
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ClearScriptPrecompiled", "precompiled\ClearScriptPrecompiled\ClearScriptPrecompiled.xproj", "{92B9BBB1-DDC9-45D9-A27E-1358A085FA6E}"
1820
EndProject
1921
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JurassicPrecompiled", "precompiled\JurassicPrecompiled\JurassicPrecompiled.xproj", "{6108205A-FDC7-4B5B-AB57-33E03B2E418A}"
@@ -34,6 +36,14 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JavaScriptEngineSwitcher.Ch
3436
EndProject
3537
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JavaScriptEngineSwitcher.Tests", "test\JavaScriptEngineSwitcher.Tests\JavaScriptEngineSwitcher.Tests.xproj", "{E95FDEF6-18A0-4E26-8FDF-B4B590E6EDAF}"
3638
EndProject
39+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JavaScriptEngineSwitcher.Sample.Resources", "samples\JavaScriptEngineSwitcher.Sample.Resources\JavaScriptEngineSwitcher.Sample.Resources.xproj", "{62F0C0AD-15BC-42CE-9BD2-49F506FEAA54}"
40+
EndProject
41+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JavaScriptEngineSwitcher.Sample.Logic", "samples\JavaScriptEngineSwitcher.Sample.Logic\JavaScriptEngineSwitcher.Sample.Logic.xproj", "{C434E1B5-0463-4E58-8336-87F822D07B41}"
42+
EndProject
43+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JavaScriptEngineSwitcher.Sample.AspNetCore1.Mvc1", "samples\JavaScriptEngineSwitcher.Sample.AspNetCore1.Mvc1\JavaScriptEngineSwitcher.Sample.AspNetCore1.Mvc1.xproj", "{C790AD7F-55C6-4106-8D8C-8F901B7FF245}"
44+
EndProject
45+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1", "samples\JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1\JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1.xproj", "{5CA92021-B75A-40AF-B5AA-500BAF76B4D6}"
46+
EndProject
3747
Global
3848
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3949
Debug|Any CPU = Debug|Any CPU
@@ -52,6 +62,10 @@ Global
5262
{13559975-F99D-4B93-BF46-227C0B6E0DFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
5363
{13559975-F99D-4B93-BF46-227C0B6E0DFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
5464
{13559975-F99D-4B93-BF46-227C0B6E0DFB}.Release|Any CPU.Build.0 = Release|Any CPU
65+
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66+
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Debug|Any CPU.Build.0 = Debug|Any CPU
67+
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Release|Any CPU.ActiveCfg = Release|Any CPU
68+
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Release|Any CPU.Build.0 = Release|Any CPU
5569
{B3C4AA95-2227-47DD-B58C-22FA589CB28D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5670
{B3C4AA95-2227-47DD-B58C-22FA589CB28D}.Debug|Any CPU.Build.0 = Debug|Any CPU
5771
{B3C4AA95-2227-47DD-B58C-22FA589CB28D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -76,10 +90,22 @@ Global
7690
{E95FDEF6-18A0-4E26-8FDF-B4B590E6EDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
7791
{E95FDEF6-18A0-4E26-8FDF-B4B590E6EDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
7892
{E95FDEF6-18A0-4E26-8FDF-B4B590E6EDAF}.Release|Any CPU.Build.0 = Release|Any CPU
79-
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80-
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Debug|Any CPU.Build.0 = Debug|Any CPU
81-
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Release|Any CPU.ActiveCfg = Release|Any CPU
82-
{5B693A49-BEC2-4532-ADFE-80C4AA930E27}.Release|Any CPU.Build.0 = Release|Any CPU
93+
{62F0C0AD-15BC-42CE-9BD2-49F506FEAA54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94+
{62F0C0AD-15BC-42CE-9BD2-49F506FEAA54}.Debug|Any CPU.Build.0 = Debug|Any CPU
95+
{62F0C0AD-15BC-42CE-9BD2-49F506FEAA54}.Release|Any CPU.ActiveCfg = Release|Any CPU
96+
{62F0C0AD-15BC-42CE-9BD2-49F506FEAA54}.Release|Any CPU.Build.0 = Release|Any CPU
97+
{C434E1B5-0463-4E58-8336-87F822D07B41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
98+
{C434E1B5-0463-4E58-8336-87F822D07B41}.Debug|Any CPU.Build.0 = Debug|Any CPU
99+
{C434E1B5-0463-4E58-8336-87F822D07B41}.Release|Any CPU.ActiveCfg = Release|Any CPU
100+
{C434E1B5-0463-4E58-8336-87F822D07B41}.Release|Any CPU.Build.0 = Release|Any CPU
101+
{5CA92021-B75A-40AF-B5AA-500BAF76B4D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
102+
{5CA92021-B75A-40AF-B5AA-500BAF76B4D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
103+
{5CA92021-B75A-40AF-B5AA-500BAF76B4D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
104+
{5CA92021-B75A-40AF-B5AA-500BAF76B4D6}.Release|Any CPU.Build.0 = Release|Any CPU
105+
{C790AD7F-55C6-4106-8D8C-8F901B7FF245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
106+
{C790AD7F-55C6-4106-8D8C-8F901B7FF245}.Debug|Any CPU.Build.0 = Debug|Any CPU
107+
{C790AD7F-55C6-4106-8D8C-8F901B7FF245}.Release|Any CPU.ActiveCfg = Release|Any CPU
108+
{C790AD7F-55C6-4106-8D8C-8F901B7FF245}.Release|Any CPU.Build.0 = Release|Any CPU
83109
EndGlobalSection
84110
GlobalSection(SolutionProperties) = preSolution
85111
HideSolutionNode = FALSE
@@ -88,12 +114,16 @@ Global
88114
{92B9BBB1-DDC9-45D9-A27E-1358A085FA6E} = {D36F06D5-6CE7-4295-B035-513A99013A26}
89115
{6108205A-FDC7-4B5B-AB57-33E03B2E418A} = {D36F06D5-6CE7-4295-B035-513A99013A26}
90116
{13559975-F99D-4B93-BF46-227C0B6E0DFB} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
117+
{5B693A49-BEC2-4532-ADFE-80C4AA930E27} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
91118
{B3C4AA95-2227-47DD-B58C-22FA589CB28D} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
92119
{C24E1F3C-5680-463A-8703-B9F40BCDAC77} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
93120
{D31B5A77-8018-4D76-B372-325564385B2D} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
94121
{22D73C6E-5F35-497B-A93B-F9EAAAE4DDAA} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
95122
{2EFFFC6B-E642-477F-B537-4241EBD93410} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
96123
{E95FDEF6-18A0-4E26-8FDF-B4B590E6EDAF} = {53B43213-2E66-42C2-8476-600A2FD2DA75}
97-
{5B693A49-BEC2-4532-ADFE-80C4AA930E27} = {0C281F46-F1D2-4A1C-8560-375EDA65D680}
124+
{62F0C0AD-15BC-42CE-9BD2-49F506FEAA54} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
125+
{C434E1B5-0463-4E58-8336-87F822D07B41} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
126+
{5CA92021-B75A-40AF-B5AA-500BAF76B4D6} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
127+
{C790AD7F-55C6-4106-8D8C-8F901B7FF245} = {E5989CB5-AACE-4D35-A8EE-26942F140DA3}
98128
EndGlobalSection
99129
EndGlobal

JavaScriptEngineSwitcher.Net4.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptEngineSwitcher.Te
4040
EndProject
4141
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptEngineSwitcher.Sample.Resources.Net40", "samples\JavaScriptEngineSwitcher.Sample.Resources\JavaScriptEngineSwitcher.Sample.Resources.Net40.csproj", "{6860B000-AA2E-4607-BBE0-A406D901DFDE}"
4242
EndProject
43-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptEngineSwitcher.Sample.Logic.Net40", "samples\JavaScriptEngineSwitcher.Sample.Logic.Net40\JavaScriptEngineSwitcher.Sample.Logic.Net40.csproj", "{4E8DC7D0-8121-4FB3-9DF5-788B755852A2}"
43+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptEngineSwitcher.Sample.Logic.Net40", "samples\JavaScriptEngineSwitcher.Sample.Logic\JavaScriptEngineSwitcher.Sample.Logic.Net40.csproj", "{4E8DC7D0-8121-4FB3-9DF5-788B755852A2}"
4444
EndProject
4545
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4.Net40", "samples\JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4\JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4.Net40.csproj", "{8124DF18-4A0B-4648-8B90-4A6D3E4EF2F3}"
4646
EndProject

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"projects": [ "precompiled", "src", "test" ],
2+
"projects": [ "precompiled", "src", "test", "samples" ],
33
"sdk": {
44
"version": "1.0.0-preview2-003121"
55
}

samples/JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4/Views/Home/Demo.cshtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@
6161
)
6262
</div>
6363
}
64-
65-
@if (Model.Result.Errors.Count > 0)
64+
else
6665
{
6766
@Html.Partial("_JsEvaluationErrorList", Model.Result.Errors)
6867
}

samples/JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js"> <!--<![endif]-->
77
<head>
88
<meta charset="utf-8">
9-
<title>@if (!string.IsNullOrEmpty(ViewBag.Title)) {<text>@ViewBag.Title | </text>}JsEngineSwitcher Sample ASP.NET 4.0 MVC 4 Site</title>
9+
<title>@if (!string.IsNullOrEmpty(ViewBag.Title)) {<text>@ViewBag.Title | </text>}JavaScriptEngineSwitcher Sample ASP.NET 4.0 MVC 4 Site</title>
1010
<link href="//fonts.googleapis.com/css?family=Open+Sans:700,600,400,300&subset=latin,cyrillic" rel="stylesheet">
1111
<link href="//fonts.googleapis.com/css?family=Open+Sans+Condensed:700,300&subset=latin,cyrillic" rel="stylesheet">
1212
<link href="~/styles/build/common-styles.min.css" rel="stylesheet">

samples/JavaScriptEngineSwitcher.Sample.AspNet4.Mvc4/styles/app.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
@import "lib/bootstrap/utilities.less";
5656
//@import "lib/bootstrap/responsive-utilities.less";
5757

58-
// WebMarkupMin specs
58+
// JavaScriptEngineSwitcher specs
5959
@import "variables.less";
6060
@import "mixins.less";
6161

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "bower_components"
3+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System.Threading.Tasks;
2+
3+
using Microsoft.AspNetCore.Hosting;
4+
using Microsoft.AspNetCore.Html;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.Extensions.Configuration;
7+
8+
using JavaScriptEngineSwitcher.Sample.Logic.Models;
9+
using JavaScriptEngineSwitcher.Sample.Logic.Services;
10+
11+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore1.Mvc1.Controllers
12+
{
13+
public class HomeController : Controller
14+
{
15+
private readonly FileContentService _fileContentService;
16+
private readonly JsEvaluationService _jsEvaluationService;
17+
18+
19+
public HomeController(
20+
IConfigurationRoot configuration,
21+
IHostingEnvironment hostingEnvironment,
22+
JsEvaluationService jsEvaluationService)
23+
{
24+
string textContentDirectoryPath = configuration
25+
.GetSection("jsengineswitcher")
26+
.GetSection("Samples")["TextContentDirectoryPath"]
27+
;
28+
29+
_fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
30+
_jsEvaluationService = jsEvaluationService;
31+
}
32+
33+
34+
[ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
35+
public IActionResult Index()
36+
{
37+
ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
38+
39+
return View();
40+
}
41+
42+
[HttpGet]
43+
[ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
44+
public IActionResult Demo()
45+
{
46+
var model = _jsEvaluationService.GetInitializationData();
47+
48+
return View(model);
49+
}
50+
51+
[HttpPost]
52+
public async Task<IActionResult> Demo(JsEvaluationViewModel editedModel)
53+
{
54+
var model = _jsEvaluationService.GetInitializationData();
55+
await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
56+
57+
if (ModelState.IsValid)
58+
{
59+
model = _jsEvaluationService.Evaluate(model);
60+
61+
ModelState.Clear();
62+
}
63+
64+
return View(model);
65+
}
66+
67+
[ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
68+
public IActionResult Contact()
69+
{
70+
ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
71+
72+
return View();
73+
}
74+
75+
public IActionResult Error()
76+
{
77+
return View();
78+
}
79+
}
80+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Text.RegularExpressions;
2+
3+
using Microsoft.AspNetCore.Html;
4+
using Microsoft.AspNetCore.Mvc.Rendering;
5+
6+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore1.Mvc1.Infrastructure.Helpers
7+
{
8+
public static class CommonExtensions
9+
{
10+
public static HtmlString EncodedReplace(this IHtmlHelper htmlHelper, string input,
11+
string pattern, string replacement)
12+
{
13+
return new HtmlString(Regex.Replace(htmlHelper.Encode(input), pattern, replacement));
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
3+
using Microsoft.AspNetCore.Razor.TagHelpers;
4+
5+
namespace JavaScriptEngineSwitcher.Sample.AspNetCore1.Mvc1.Infrastructure.TagHelpers
6+
{
7+
[HtmlTargetElement("conditional-comment")]
8+
public class ConditionalCommentTagHelper : TagHelper
9+
{
10+
[HtmlAttributeName("type")]
11+
public ConditionalCommentType CommentType { get; set; }
12+
13+
[HtmlAttributeName("expression")]
14+
public string Expression { get; set; }
15+
16+
17+
public override void Process(TagHelperContext context, TagHelperOutput output)
18+
{
19+
output.TagName = null;
20+
21+
ConditionalCommentType type = CommentType;
22+
23+
string ifCommentStartPart;
24+
string ifCommentEndPart;
25+
26+
switch (type)
27+
{
28+
case ConditionalCommentType.Hidden:
29+
ifCommentStartPart = "<!--[if ";
30+
ifCommentEndPart = "]>";
31+
32+
break;
33+
case ConditionalCommentType.RevealedValidating:
34+
ifCommentStartPart = "<!--[if ";
35+
ifCommentEndPart = "]><!-->";
36+
37+
break;
38+
case ConditionalCommentType.RevealedValidatingSimplified:
39+
ifCommentStartPart = "<!--[if ";
40+
ifCommentEndPart = "]>-->";
41+
42+
break;
43+
case ConditionalCommentType.Revealed:
44+
ifCommentStartPart = "<![if ";
45+
ifCommentEndPart = "]>";
46+
47+
break;
48+
default:
49+
throw new NotSupportedException();
50+
}
51+
52+
TagHelperContent preContent = output.PreContent;
53+
preContent.AppendHtml(ifCommentStartPart);
54+
preContent.AppendHtml(Expression);
55+
preContent.AppendHtml(ifCommentEndPart);
56+
57+
string endIfComment;
58+
59+
switch (type)
60+
{
61+
case ConditionalCommentType.Hidden:
62+
endIfComment = "<![endif]-->";
63+
break;
64+
case ConditionalCommentType.RevealedValidating:
65+
case ConditionalCommentType.RevealedValidatingSimplified:
66+
endIfComment = "<!--<![endif]-->";
67+
break;
68+
case ConditionalCommentType.Revealed:
69+
endIfComment = "<![endif]>";
70+
break;
71+
default:
72+
throw new NotSupportedException();
73+
}
74+
75+
output.PostContent.AppendHtml(endIfComment);
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)