@@ -35,9 +35,9 @@ public EngineInstance Context
35
35
public override PropertyDescriptor GetOwnProperty ( String propertyName )
36
36
{
37
37
// If we have a numeric indexer and the property is numeric
38
- int numericIndex ;
38
+ var numericIndex = default ( Int32 ) ;
39
39
40
- if ( _numericIndexer != null && int . TryParse ( propertyName , out numericIndex ) )
40
+ if ( _numericIndexer != null && Int32 . TryParse ( propertyName , out numericIndex ) )
41
41
return new PropertyDescriptor ( _numericIndexer . GetMethod . Invoke ( _value , new Object [ ] { numericIndex } ) . ToJsValue ( _engine ) , false , false , false ) ;
42
42
43
43
// Else a string property
@@ -46,8 +46,8 @@ public override PropertyDescriptor GetOwnProperty(String propertyName)
46
46
// Eg. object.callMethod1() vs object['callMethod1'] is not necessarily the same if the object has a string indexer?? (I'm not an ECMA expert!)
47
47
// node.attributes is one such object - has both a string and numeric indexer
48
48
// This GetOwnProperty override might need an additional parameter to let us know this was called via an indexer
49
- if ( _stringIndexer != null && Properties . ContainsKey ( propertyName ) == false )
50
- return new PropertyDescriptor ( _stringIndexer . GetMethod . Invoke ( _value , new Object [ ] { propertyName } ) . ToJsValue ( _engine ) , false , false , false ) ;
49
+ if ( _stringIndexer != null && ! Properties . ContainsKey ( propertyName ) )
50
+ return new PropertyDescriptor ( _stringIndexer . GetMethod . Invoke ( _value , new Object [ ] { propertyName } ) . ToJsValue ( _engine ) , false , false , false ) ;
51
51
52
52
// Else try to return a registered property
53
53
return base . GetOwnProperty ( propertyName ) ;
@@ -85,9 +85,8 @@ void SetEvents(EventInfo[] eventInfos)
85
85
86
86
foreach ( var name in names . Select ( m => m . OfficialName ) )
87
87
{
88
- FastSetProperty ( name , new PropertyDescriptor (
89
- new DomFunctionInstance ( this , eventInfo . RaiseMethod ) ,
90
- new DomFunctionInstance ( this , eventInfo . AddMethod ) , false , false ) ) ;
88
+ var eventInstance = new DomEventInstance ( this , eventInfo ) ;
89
+ FastSetProperty ( name , new PropertyDescriptor ( eventInstance . Getter , eventInstance . Setter , false , false ) ) ;
91
90
}
92
91
}
93
92
}
@@ -116,8 +115,8 @@ void SetProperties(IEnumerable<PropertyInfo> properties)
116
115
foreach ( var name in names . Select ( m => m . OfficialName ) )
117
116
{
118
117
FastSetProperty ( name , new PropertyDescriptor (
119
- new DomFunctionInstance ( this , property . GetMethod ) ,
120
- new DomFunctionInstance ( this , property . SetMethod ) , false , false ) ) ;
118
+ new DomFunctionInstance ( _engine , property . GetMethod ) ,
119
+ new DomFunctionInstance ( _engine , property . SetMethod ) , false , false ) ) ;
121
120
}
122
121
}
123
122
}
@@ -136,8 +135,8 @@ void SetMethods(IEnumerable<MethodInfo> methods)
136
135
// to pick depending on the number (and probably types) of arguments.
137
136
if ( Properties . ContainsKey ( name ) )
138
137
continue ;
139
-
140
- FastAddProperty ( name , new DomFunctionInstance ( this , method ) , false , false , false ) ;
138
+
139
+ FastAddProperty ( name , new DomFunctionInstance ( _engine , method ) , false , false , false ) ;
141
140
}
142
141
}
143
142
}
0 commit comments