Skip to content

Commit 62d0284

Browse files
committed
Add constructors from core and scripting #12
1 parent c77426c commit 62d0284

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

AngleSharp.Scripting.JavaScript/EngineInstance.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public EngineInstance(IWindow window, IDictionary<String, Object> assignments)
3030
_constructors = new DomConstructors(this);
3131
_constructors.Configure();
3232

33-
foreach (var type in typeof(INode).Assembly.ExportedTypes)
34-
this.AddConstructor(_window, type);
33+
this.AddConstructors(_window, typeof(INode));
34+
this.AddConstructors(_window, this.GetType());
3535
}
3636

3737
public DomConstructors Constructors

AngleSharp.Scripting.JavaScript/Extensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ public static String[] GetParameterNames(this MethodInfo method)
161161
return method != null ? method.GetParameters().Select(m => m.Name).ToArray() : null;
162162
}
163163

164+
public static void AddConstructors(this EngineInstance engine, ObjectInstance obj, Type type)
165+
{
166+
foreach (var exportedType in type.Assembly.ExportedTypes)
167+
engine.AddConstructor(obj, exportedType);
168+
}
169+
164170
public static void AddConstructor(this EngineInstance engine, ObjectInstance obj, Type type)
165171
{
166172
var info = type.GetConstructors().FirstOrDefault(m =>

0 commit comments

Comments
 (0)