Skip to content

Commit 6a2dbb6

Browse files
committed
Version 1.2.0:
1. From JavaScriptEngineSwitcher.V8 and JavaScriptEngineSwitcher.Jint removed dependency on `System.Web.Extensions.dll`; 2. All assemblies is now targeted on the .NET Framework 4 Client Profile; 3. In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 1.5.0; 4. In JavaScriptEngineSwitcher.Jint added support of Jint version of October 9, 2014.
1 parent bb7685d commit 6a2dbb6

40 files changed

+317
-145
lines changed

Diff for: Binaries/ClearScript/ClearScript.dll

512 Bytes
Binary file not shown.

Diff for: Binaries/ClearScript/x64/ClearScriptV8-64.dll

0 Bytes
Binary file not shown.

Diff for: Binaries/ClearScript/x86/ClearScriptV8-32.dll

0 Bytes
Binary file not shown.

Diff for: Binaries/Jint/Jint.dll

10.5 KB
Binary file not shown.

Diff for: Binaries/Jurassic/Jurassic.dll

0 Bytes
Binary file not shown.

Diff for: CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Change log
22
==========
33

4+
## October 13, 2014 - v1.2.0
5+
6+
* From JavaScriptEngineSwitcher.V8 and JavaScriptEngineSwitcher.Jint removed dependency on `System.Web.Extensions.dll`
7+
* All assemblies is now targeted on the .NET Framework 4 Client Profile
8+
* In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 1.5.0
9+
* In JavaScriptEngineSwitcher.Jint added support of Jint version of October 9, 2014
10+
411
## September 17, 2014 - v1.1.13
512

613
* In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version of September 6, 2014

Diff for: JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<AssemblyName>JavaScriptEngineSwitcher.Core</AssemblyName>
1212
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
1415
</PropertyGroup>
1516
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617
<DebugSymbols>true</DebugSymbols>
@@ -68,6 +69,7 @@
6869
</Compile>
6970
<Compile Include="Undefined.cs" />
7071
<Compile Include="Utilities\StringBuilderExtensions.cs" />
72+
<Compile Include="Utilities\TypeConverter.cs" />
7173
<Compile Include="Utilities\Utils.cs" />
7274
</ItemGroup>
7375
<ItemGroup>

Diff for: JavaScriptEngineSwitcher.Core/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
[assembly: ComVisible(false)]
1414
[assembly: Guid("9f7e9fff-da85-4609-8bee-bdead5a3afe2")]
1515

16-
[assembly: AssemblyVersion("1.1.3.0")]
17-
[assembly: AssemblyFileVersion("1.1.3.0")]
16+
[assembly: AssemblyVersion("1.2.0.0")]
17+
[assembly: AssemblyFileVersion("1.2.0.0")]

Diff for: JavaScriptEngineSwitcher.Core/Resources/Strings.Designer.cs

+19-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: JavaScriptEngineSwitcher.Core/Resources/Strings.resx

+6
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<data name="Common_AssemblyNameIsEmpty" xml:space="preserve">
127127
<value>You do not specified a name of assembly.</value>
128128
</data>
129+
<data name="Common_CannotConvertObjectToType" xml:space="preserve">
130+
<value>Cannot convert object of type `{0}` to type `{1}`.</value>
131+
</data>
129132
<data name="Common_EnumValueConversionFailed" xml:space="preserve">
130133
<value>Can not convert value '{0}' of enumeration type `{1}` to value of enumeration type `{2}`.</value>
131134
</data>
@@ -144,6 +147,9 @@
144147
<data name="Common_ValueIsNull" xml:space="preserve">
145148
<value>Value cannot be null.</value>
146149
</data>
150+
<data name="Common_ValueTypeCannotBeNull" xml:space="preserve">
151+
<value>Cannot convert null to a value type.</value>
152+
</data>
147153
<data name="Configuration_DefaultJsEngineNotSpecified" xml:space="preserve">
148154
<value>Default JavaScript engine not specified.</value>
149155
</data>

Diff for: JavaScriptEngineSwitcher.Core/Resources/Strings.ru-ru.resx

+6
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<data name="Common_AssemblyNameIsEmpty" xml:space="preserve">
127127
<value>Вы не указали имя сборки!</value>
128128
</data>
129+
<data name="Common_CannotConvertObjectToType" xml:space="preserve">
130+
<value>Невозможно преобразовать объект типа `{0}` в тип `{1}`!</value>
131+
</data>
129132
<data name="Common_EnumValueConversionFailed" xml:space="preserve">
130133
<value>Невозможно преобразовать значение "{0}" перечислимого типа `{1}` в значение перечислимого типа `{2}`!</value>
131134
</data>
@@ -144,6 +147,9 @@
144147
<data name="Common_ValueIsNull" xml:space="preserve">
145148
<value>Значение не должно быть равно null!</value>
146149
</data>
150+
<data name="Common_ValueTypeCannotBeNull" xml:space="preserve">
151+
<value>Невозможно преобразовать null в значимый тип!</value>
152+
</data>
147153
<data name="Configuration_DefaultJsEngineNotSpecified" xml:space="preserve">
148154
<value>Не указан JavaScript-движок, который должен использоваться по умолчанию!</value>
149155
</data>
+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
namespace JavaScriptEngineSwitcher.Core.Utilities
2+
{
3+
using System;
4+
using System.ComponentModel;
5+
using System.Globalization;
6+
using OriginalTypeConverter = System.ComponentModel.TypeConverter;
7+
8+
using Resources;
9+
10+
/// <summary>
11+
/// Type converter
12+
/// </summary>
13+
public static class TypeConverter
14+
{
15+
/// <summary>
16+
/// Converts the specified value to the specified type
17+
/// </summary>
18+
/// <typeparam name="T">The type to convert the value to</typeparam>
19+
/// <param name="value">The value to convert</param>
20+
/// <returns>The value that has been converted to the target type</returns>
21+
public static T ConvertToType<T>(object value)
22+
{
23+
return (T)ConvertToType(value, typeof(T));
24+
}
25+
26+
/// <summary>
27+
/// Converts the specified value to the specified type
28+
/// </summary>
29+
/// <param name="value">The value to convert</param>
30+
/// <param name="targetType">The type to convert the value to</param>
31+
/// <returns>The value that has been converted to the target type</returns>
32+
public static object ConvertToType(object value, Type targetType)
33+
{
34+
object result;
35+
ConvertObjectToType(value, targetType, true, out result);
36+
37+
return result;
38+
}
39+
40+
/// <summary>
41+
/// Converts the specified value to the specified type.
42+
/// A return value indicates whether the conversion succeeded.
43+
/// </summary>
44+
/// <typeparam name="T">The type to convert the value to</typeparam>
45+
/// <param name="value">The value to convert</param>
46+
/// <param name="convertedValue">The value that has been converted to the target type</param>
47+
/// <returns>Result of conversion (true - success; false - failure)</returns>
48+
public static bool TryConvertToType<T>(object value, out T convertedValue)
49+
{
50+
object resultValue;
51+
52+
bool result = TryConvertToType(value, typeof(T), out resultValue);
53+
convertedValue = (T)resultValue;
54+
55+
return result;
56+
}
57+
58+
/// <summary>
59+
/// Converts the specified value to the specified type.
60+
/// A return value indicates whether the conversion succeeded.
61+
/// </summary>
62+
/// <param name="value">The value to convert</param>
63+
/// <param name="targetType">The type to convert the value to</param>
64+
/// <param name="convertedValue">The value that has been converted to the target type</param>
65+
/// <returns>Result of conversion (true - success; false - failure)</returns>
66+
public static bool TryConvertToType(object value, Type targetType, out object convertedValue)
67+
{
68+
bool result = ConvertObjectToType(value, targetType, false, out convertedValue);
69+
70+
return result;
71+
}
72+
73+
private static bool ConvertObjectToType(object obj, Type type, bool throwOnError,
74+
out object convertedObject)
75+
{
76+
if (obj == null)
77+
{
78+
if (IsNonNullableValueType(type))
79+
{
80+
if (throwOnError)
81+
{
82+
throw new InvalidOperationException(Strings.Common_ValueTypeCannotBeNull);
83+
}
84+
85+
convertedObject = null;
86+
return false;
87+
}
88+
89+
convertedObject = null;
90+
return true;
91+
}
92+
93+
if (type != null && obj.GetType() != type)
94+
{
95+
return InnerConvertObjectToType(obj, type, throwOnError, out convertedObject);
96+
}
97+
98+
convertedObject = obj;
99+
return true;
100+
}
101+
102+
private static bool InnerConvertObjectToType(object obj, Type type, bool throwOnError,
103+
out object convertedObject)
104+
{
105+
OriginalTypeConverter converter = TypeDescriptor.GetConverter(type);
106+
107+
if (converter.CanConvertFrom(obj.GetType()))
108+
{
109+
try
110+
{
111+
convertedObject = converter.ConvertFrom(null, CultureInfo.InvariantCulture, obj);
112+
return true;
113+
}
114+
catch
115+
{
116+
if (throwOnError)
117+
{
118+
throw;
119+
}
120+
121+
convertedObject = null;
122+
return false;
123+
}
124+
}
125+
126+
if (converter.CanConvertFrom(typeof(string)) && !(obj is DateTime))
127+
{
128+
try
129+
{
130+
string text = TypeDescriptor.GetConverter(obj).ConvertToInvariantString(obj);
131+
132+
convertedObject = converter.ConvertFromInvariantString(text);
133+
return true;
134+
}
135+
catch
136+
{
137+
if (throwOnError)
138+
{
139+
throw;
140+
}
141+
142+
convertedObject = null;
143+
return false;
144+
}
145+
}
146+
147+
if (type.IsInstanceOfType(obj))
148+
{
149+
convertedObject = obj;
150+
return true;
151+
}
152+
153+
if (throwOnError)
154+
{
155+
throw new InvalidOperationException(
156+
string.Format(Strings.Common_CannotConvertObjectToType, obj.GetType(), type)
157+
);
158+
}
159+
160+
convertedObject = null;
161+
return false;
162+
}
163+
164+
private static bool IsNonNullableValueType(Type type)
165+
{
166+
if (type == null || !type.IsValueType)
167+
{
168+
return false;
169+
}
170+
171+
if (type.IsGenericType)
172+
{
173+
return (type.GetGenericTypeDefinition() != typeof(Nullable<>));
174+
}
175+
176+
return true;
177+
}
178+
}
179+
}

Diff for: JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<FileAlignment>512</FileAlignment>
1414
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
1515
<RestorePackages>true</RestorePackages>
16+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
1617
</PropertyGroup>
1718
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1819
<DebugSymbols>true</DebugSymbols>
@@ -38,13 +39,12 @@
3839
<AssemblyOriginatorKeyFile>..\JavaScriptEngineSwitcher.snk</AssemblyOriginatorKeyFile>
3940
</PropertyGroup>
4041
<ItemGroup>
41-
<Reference Include="Jint, Version=2.1.0.0, Culture=neutral, PublicKeyToken=2e92ba9c8d81157f, processorArchitecture=MSIL">
42+
<Reference Include="Jint, Version=2.3.0.0, Culture=neutral, PublicKeyToken=2e92ba9c8d81157f, processorArchitecture=MSIL">
4243
<SpecificVersion>False</SpecificVersion>
4344
<HintPath>..\Binaries\Jint\Jint.dll</HintPath>
4445
</Reference>
4546
<Reference Include="System" />
4647
<Reference Include="System.Core" />
47-
<Reference Include="System.Web.Extensions" />
4848
</ItemGroup>
4949
<ItemGroup>
5050
<Compile Include="JintJsEngine.cs" />

0 commit comments

Comments
 (0)