Skip to content

Commit f0f2e3c

Browse files
committed
In the JsEngineFactoryCollection class was added a Count property and GetRegisteredFactories method
1 parent 7d60f26 commit f0f2e3c

File tree

3 files changed

+23
-50
lines changed

3 files changed

+23
-50
lines changed

src/JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,7 @@
1313
<Description>JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines (MSIE JavaScript Engine for .NET, Microsoft ClearScript.V8, Jurassic, Jint, ChakraCore, VroomJs and NiL.JS). This library allows you to quickly and easily switch to using of another JavaScript engine.</Description>
1414
<PackageIconUrl>https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Core_Logo128x128.png</PackageIconUrl>
1515
<PackageTags>JavaScriptEngineSwitcher;JavaScript;ECMAScript</PackageTags>
16-
<PackageReleaseNotes>1. In the `JsEngineSwitcher` class a `Instance` property was renamed to the `Current` property;
17-
2. Now you can implement your own version of the `JsEngineSwitcher` class;
18-
3. Format of the error messages was unified;
19-
4. Created a new exception classes: `JsCompilationException`, `JsEngineException`, `JsFatalException`, `JsInterruptedException`, `JsTimeoutException`, `JsScriptException` and `JsUsageException`. These exceptions are responsible for handling errors, some of which were previously handled by the `JsRuntimeException` class;
20-
5. In the `JsException` class was added two new properties: `Category` and `Description`;
21-
6. From the `JsRuntimeException` class was removed one property - `ErrorCode`;
22-
7. In the `JsRuntimeException` class was added three new properties: `Type`, `DocumentName` and `CallStack`;
23-
8. `JsEngineLoadException` class now is inherited from the `JsEngineException` class;
24-
9. Removed a `EmptyValueException` class;
25-
10. `Format` method of the `JsErrorHelpers` class was renamed to the `GenerateErrorDetails`;
26-
11. Part of the auxiliary code was moved to external libraries: PolyfillsForOldDotNet and AdvancedStringBuilder;
27-
12. In `IJsEngine` interface was added two new properties: `SupportsScriptInterruption` and `SupportsScriptPrecompilation`, and four new methods: `Interrupt`, `Precompile`, `PrecompileFile` and `PrecompileResource`;
28-
13. Added support of .NET Standard 2.0.</PackageReleaseNotes>
16+
<PackageReleaseNotes>In the `JsEngineFactoryCollection` class was added a `Count` property and `GetRegisteredFactories` method.</PackageReleaseNotes>
2917
</PropertyGroup>
3018

3119
<Import Project="../../build/common.props" />

src/JavaScriptEngineSwitcher.Core/JsEngineFactoryCollection.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Collections.ObjectModel;
45

56
namespace JavaScriptEngineSwitcher.Core
67
{
@@ -15,6 +16,23 @@ public sealed class JsEngineFactoryCollection : IEnumerable<IJsEngineFactory>
1516
private readonly Dictionary<string, IJsEngineFactory> _factories =
1617
new Dictionary<string, IJsEngineFactory>();
1718

19+
/// <summary>
20+
/// Gets a number of factories in the collection
21+
/// </summary>
22+
public int Count
23+
{
24+
get { return _factories.Count; }
25+
}
26+
27+
28+
/// <summary>
29+
/// Gets all registered factories
30+
/// </summary>
31+
/// <returns>A read-only collection of all factories in the collection</returns>
32+
public ReadOnlyCollection<IJsEngineFactory> GetRegisteredFactories()
33+
{
34+
return new List<IJsEngineFactory>(_factories.Values).AsReadOnly();
35+
}
1836

1937
/// <summary>
2038
/// Gets a factory by JS engine name
@@ -91,25 +109,16 @@ public void Clear()
91109
_factories.Clear();
92110
}
93111

94-
/// <summary>
95-
/// Gets an enumerator for all factories in the collection
96-
/// </summary>
97-
/// <returns>Enumerator for all factories in the collection</returns>
98-
private IEnumerator<IJsEngineFactory> InnerGetEnumerator()
99-
{
100-
return _factories.Values.GetEnumerator();
101-
}
102-
103112
#region IEnumerable implementation
104113

105114
public IEnumerator<IJsEngineFactory> GetEnumerator()
106115
{
107-
return InnerGetEnumerator();
116+
return _factories.Values.GetEnumerator();
108117
}
109118

110119
IEnumerator IEnumerable.GetEnumerator()
111120
{
112-
return InnerGetEnumerator();
121+
return _factories.Values.GetEnumerator();
113122
}
114123

115124
#endregion

src/JavaScriptEngineSwitcher.Core/readme.txt

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,8 @@
2020
=============
2121
RELEASE NOTES
2222
=============
23-
1. In the `JsEngineSwitcher` class a `Instance` property was renamed to the
24-
`Current` property;
25-
2. Now you can implement your own version of the `JsEngineSwitcher` class;
26-
3. Format of the error messages was unified;
27-
4. Created a new exception classes: `JsCompilationException`,
28-
`JsEngineException`, `JsFatalException`, `JsInterruptedException`,
29-
`JsTimeoutException`, `JsScriptException` and `JsUsageException`. These
30-
exceptions are responsible for handling errors, some of which were
31-
previously handled by the `JsRuntimeException` class;
32-
5. In the `JsException` class was added two new properties: `Category` and
33-
`Description`;
34-
6. From the `JsRuntimeException` class was removed one property - `ErrorCode`;
35-
7. In the `JsRuntimeException` class was added three new properties: `Type`,
36-
`DocumentName` and `CallStack`;
37-
8. `JsEngineLoadException` class now is inherited from the `JsEngineException`
38-
class;
39-
9. Removed a `EmptyValueException` class;
40-
10. `Format` method of the `JsErrorHelpers` class was renamed to the
41-
`GenerateErrorDetails`;
42-
11. Part of the auxiliary code was moved to external libraries:
43-
PolyfillsForOldDotNet and AdvancedStringBuilder;
44-
12. In `IJsEngine` interface was added two new properties:
45-
`SupportsScriptInterruption` and `SupportsScriptPrecompilation`, and four
46-
new methods: `Interrupt`, `Precompile`, `PrecompileFile` and
47-
`PrecompileResource`;
48-
13. Added support of .NET Standard 2.0.
23+
In the `JsEngineFactoryCollection` class was added a `Count` property and
24+
`GetRegisteredFactories` method.
4925

5026
=============
5127
DOCUMENTATION

0 commit comments

Comments
 (0)