@@ -32,11 +32,6 @@ internal abstract class HostItemBase : IReflect
32
32
/// </summary>
33
33
private readonly FieldInfo [ ] _fields ;
34
34
35
- /// <summary>
36
- /// List of field names
37
- /// </summary>
38
- private string [ ] _fieldNames ;
39
-
40
35
/// <summary>
41
36
/// List of properties
42
37
/// </summary>
@@ -71,19 +66,37 @@ protected HostItemBase(Type type, object target, JsEngineMode engineMode, bool i
71
66
72
67
BindingFlags defaultBindingFlags = ReflectionHelpers . GetDefaultBindingFlags ( instance ) ;
73
68
FieldInfo [ ] fields = _type . GetFields ( defaultBindingFlags ) ;
74
- string [ ] fieldNames = fields . Length > 0 ? Array . ConvertAll ( fields , f => f . Name ) : new string [ 0 ] ;
75
69
PropertyInfo [ ] properties = _type . GetProperties ( defaultBindingFlags ) ;
76
70
MethodInfo [ ] methods = _type . GetMethods ( defaultBindingFlags ) ;
77
- MethodInfo [ ] fullyFledgedMethods = methods . Length > 0 ?
78
- Array . FindAll ( methods , ReflectionHelpers . IsFullyFledgedMethod ) : methods ;
71
+ if ( methods . Length > 0 && properties . Length > 0 )
72
+ {
73
+ methods = ReflectionHelpers . GetFullyFledgedMethods ( methods ) ;
74
+ }
79
75
80
76
_fields = fields ;
81
- _fieldNames = fieldNames ;
82
77
_properties = properties ;
83
- _methods = fullyFledgedMethods ;
78
+ _methods = methods ;
84
79
}
85
80
86
81
82
+ private bool IsField ( string name )
83
+ {
84
+ bool isField = false ;
85
+ FieldInfo [ ] fields = _fields ;
86
+ int fieldCount = fields . Length ;
87
+
88
+ for ( int fieldIndex = 0 ; fieldIndex < fieldCount ; fieldIndex ++ )
89
+ {
90
+ if ( fields [ fieldIndex ] . Name . Equals ( name , StringComparison . Ordinal ) )
91
+ {
92
+ isField = true ;
93
+ break ;
94
+ }
95
+ }
96
+
97
+ return isField ;
98
+ }
99
+
87
100
protected abstract object InnerInvokeMember ( string name , BindingFlags invokeAttr , Binder binder , object target ,
88
101
object [ ] args , ParameterModifier [ ] modifiers , CultureInfo culture , string [ ] namedParameters ) ;
89
102
@@ -94,7 +107,7 @@ protected object InvokeStandardMember(string name, BindingFlags invokeAttr, Bind
94
107
if ( ( processedInvokeAttr . HasFlag ( BindingFlags . GetProperty )
95
108
|| processedInvokeAttr . HasFlag ( BindingFlags . SetProperty )
96
109
|| processedInvokeAttr . HasFlag ( BindingFlags . PutDispProperty ) )
97
- && Array . IndexOf ( _fieldNames , name ) != - 1 )
110
+ && IsField ( name ) )
98
111
{
99
112
if ( processedInvokeAttr . HasFlag ( BindingFlags . GetProperty ) )
100
113
{
0 commit comments