@@ -122,6 +122,7 @@ public class ArraySchema<T> : ISchemaCollection
122
122
public event KeyValueEventHandler < T , int > OnAdd ;
123
123
public event KeyValueEventHandler < T , int > OnChange ;
124
124
public event KeyValueEventHandler < T , int > OnRemove ;
125
+ private bool _hasSchemaChild = Schema . CheckSchemaChild ( typeof ( T ) ) ;
125
126
126
127
public ArraySchema ( )
127
128
{
@@ -156,7 +157,7 @@ public bool ContainsKey(object key)
156
157
157
158
public bool HasSchemaChild
158
159
{
159
- get { return typeof ( T ) . BaseType == typeof ( Schema ) ; }
160
+ get { return _hasSchemaChild ; }
160
161
}
161
162
162
163
public int Count
@@ -232,6 +233,7 @@ public class MapSchema<T> : ISchemaCollection
232
233
public event KeyValueEventHandler < T , string > OnAdd ;
233
234
public event KeyValueEventHandler < T , string > OnChange ;
234
235
public event KeyValueEventHandler < T , string > OnRemove ;
236
+ private bool _hasSchemaChild = Schema . CheckSchemaChild ( typeof ( T ) ) ;
235
237
236
238
public MapSchema ( )
237
239
{
@@ -266,7 +268,7 @@ public bool ContainsKey(object key)
266
268
267
269
public bool HasSchemaChild
268
270
{
269
- get { return typeof ( T ) . BaseType == typeof ( Schema ) ; }
271
+ get { return _hasSchemaChild ; }
270
272
}
271
273
272
274
public T this [ string key ]
@@ -760,6 +762,22 @@ protected object CreateTypeInstance(byte[] bytes, Iterator it, System.Type type)
760
762
return Activator . CreateInstance ( type ) ;
761
763
}
762
764
}
765
+
766
+ public static bool CheckSchemaChild ( System . Type toCheck ) {
767
+ System . Type generic = typeof ( Schema ) ;
768
+
769
+ while ( toCheck != null && toCheck != typeof ( object ) ) {
770
+ var cur = toCheck . IsGenericType ? toCheck . GetGenericTypeDefinition ( ) : toCheck ;
771
+
772
+ if ( generic == cur ) {
773
+ return true ;
774
+ }
775
+
776
+ toCheck = toCheck . BaseType ;
777
+ }
778
+
779
+ return false ;
780
+ }
763
781
}
764
782
765
783
public class ReflectionField : Schema
0 commit comments