Skip to content

Commit ad99ca0

Browse files
committed
JsInDotnet
1 parent db8a521 commit ad99ca0

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

JsInDotnet/JsInDotnet.csproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="JavaScriptEngineSwitcher.Jurassic" Version="3.17.4" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Remove="prism.js" />
16+
<EmbeddedResource Include="prism.js" />
17+
</ItemGroup>
18+
19+
</Project>

JsInDotnet/JsInDotnet.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30114.105
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsInDotnet", "JsInDotnet.csproj", "{BDEA3059-F794-49F2-83E6-2B727C8EA307}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{BDEA3059-F794-49F2-83E6-2B727C8EA307}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{BDEA3059-F794-49F2-83E6-2B727C8EA307}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{BDEA3059-F794-49F2-83E6-2B727C8EA307}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{BDEA3059-F794-49F2-83E6-2B727C8EA307}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

JsInDotnet/Program.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Diagnostics;
2+
using JavaScriptEngineSwitcher.Jurassic;
3+
4+
var sw = new Stopwatch();
5+
sw.Start();
6+
Console.WriteLine("Loading JurassicEngine");
7+
8+
var engine = new JurassicJsEngine();
9+
10+
Console.WriteLine("Executing prism.js");
11+
engine.ExecuteResource("JsInDotnet.prism.js", typeof(Program).Assembly);
12+
13+
Console.WriteLine("Highlighting code:");
14+
Console.WriteLine();
15+
var code = @"
16+
using System;
17+
18+
public class Test : ITest
19+
{
20+
public int ID { get; set; }
21+
public string Name { get; set; }
22+
}";
23+
Console.WriteLine(code);
24+
25+
engine.SetVariableValue("input", code);
26+
engine.SetVariableValue("lang", "csharp");
27+
28+
29+
engine.Execute($"highlighted = Prism.highlight(input, Prism.languages.csharp, lang)");
30+
string result = engine.Evaluate<string>("highlighted");
31+
32+
Console.WriteLine("Highlighed version:");
33+
Console.WriteLine(result);
34+
35+
36+
Console.WriteLine("Finished at " + sw.Elapsed.ToString());

0 commit comments

Comments
 (0)