Skip to content

Commit 8827fd1

Browse files
committed
Version 1.1.1 (In JavaScriptEngineSwitcher.V8 added support of the ClearScript version 5.3.11)
1 parent 09b0a88 commit 8827fd1

File tree

15 files changed

+141
-50
lines changed

15 files changed

+141
-50
lines changed
1.5 KB
Binary file not shown.
-512 Bytes
Binary file not shown.
-10.5 KB
Binary file not shown.
512 Bytes
Binary file not shown.
-6.5 KB
Binary file not shown.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Change log
22
==========
33

4+
## January 17, 2014 - v1.1.1
5+
6+
* In JavaScriptEngineSwitcher.V8 added support of the [ClearScript](http://clearscript.codeplex.com/) version 5.3.11 (support of V8 version 3.24.17)
7+
48
## January 16, 2014 - v1.1.0
59

610
* In JavaScriptEngineSwitcher.Msie added support of [MSIE JavaScript Engine](http://github.com/Taritsyn/MsieJavaScriptEngine) version 1.3.0
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
namespace JavaScriptEngineSwitcher.V8
2+
{
3+
using System;
4+
using System.IO;
5+
using System.Reflection;
6+
using System.Web;
7+
8+
using Resources;
9+
10+
/// <summary>
11+
/// Assembly resolver
12+
/// </summary>
13+
internal static class AssemblyResolver
14+
{
15+
/// <summary>
16+
/// Name of directory, that contains the Microsoft ClearScript.V8 assemblies
17+
/// </summary>
18+
private const string ASSEMBLY_DIRECTORY_NAME = "ClearScript.V8";
19+
20+
/// <summary>
21+
/// Name of the ClearScriptV8 assembly
22+
/// </summary>
23+
private const string ASSEMBLY_NAME = "ClearScriptV8";
24+
25+
26+
/// <summary>
27+
/// Initialize a assembly resolver
28+
/// </summary>
29+
public static void Initialize()
30+
{
31+
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler;
32+
}
33+
34+
private static Assembly AssemblyResolveHandler(object sender, ResolveEventArgs args)
35+
{
36+
if (args.Name.StartsWith(ASSEMBLY_NAME, StringComparison.OrdinalIgnoreCase))
37+
{
38+
var currentDomain = (AppDomain)sender;
39+
string platform = Environment.Is64BitProcess ? "64" : "32";
40+
41+
string binDirectoryPath = currentDomain.SetupInformation.PrivateBinPath;
42+
if (string.IsNullOrEmpty(binDirectoryPath))
43+
{
44+
// `PrivateBinPath` property is empty in test scenarios, so
45+
// need to use the `BaseDirectory` property
46+
binDirectoryPath = currentDomain.BaseDirectory;
47+
}
48+
49+
string assemblyDirectoryPath = Path.Combine(binDirectoryPath, ASSEMBLY_DIRECTORY_NAME);
50+
string assemblyFileName = string.Format("{0}-{1}.dll", ASSEMBLY_NAME, platform);
51+
string assemblyFilePath = Path.Combine(assemblyDirectoryPath, assemblyFileName);
52+
53+
if (!Directory.Exists(assemblyDirectoryPath))
54+
{
55+
if (HttpContext.Current != null)
56+
{
57+
// Fix for WebMatrix
58+
string applicationRootPath = HttpContext.Current.Server.MapPath("~");
59+
assemblyDirectoryPath = Path.Combine(applicationRootPath, ASSEMBLY_DIRECTORY_NAME);
60+
61+
if (!Directory.Exists(assemblyDirectoryPath))
62+
{
63+
throw new DirectoryNotFoundException(
64+
string.Format(Strings.Engines_ClearScriptV8AssembliesDirectoryNotFound, assemblyDirectoryPath));
65+
}
66+
67+
assemblyFilePath = Path.Combine(assemblyDirectoryPath, assemblyFileName);
68+
}
69+
else
70+
{
71+
throw new DirectoryNotFoundException(
72+
string.Format(Strings.Engines_ClearScriptV8AssembliesDirectoryNotFound, assemblyDirectoryPath));
73+
}
74+
}
75+
76+
if (!File.Exists(assemblyFilePath))
77+
{
78+
throw new FileNotFoundException(
79+
string.Format(Strings.Engines_ClearScriptV8AssemblyFileNotFound, assemblyFilePath));
80+
}
81+
82+
return Assembly.LoadFile(assemblyFilePath);
83+
}
84+
85+
return null;
86+
}
87+
}
88+
}

JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<Reference Include="Microsoft.CSharp" />
4747
</ItemGroup>
4848
<ItemGroup>
49+
<Compile Include="AssemblyResolver.cs" />
4950
<Compile Include="Properties\AssemblyInfo.cs" />
5051
<Compile Include="Resources\Strings.Designer.cs">
5152
<AutoGen>True</AutoGen>

JavaScriptEngineSwitcher.V8/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
[assembly: ComVisible(false)]
1414
[assembly: Guid("684edd94-43fe-4486-a4f3-6b9197d10ebf")]
1515

16-
[assembly: AssemblyVersion("1.1.0.0")]
17-
[assembly: AssemblyFileVersion("1.1.0.0")]
16+
[assembly: AssemblyVersion("1.1.1.0")]
17+
[assembly: AssemblyFileVersion("1.1.1.0")]

JavaScriptEngineSwitcher.V8/Resources/Strings.Designer.cs

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)