1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

!B 没有过滤保护和内部等其他类型字段,导致出现多次

This commit is contained in:
Icarus 2019-09-22 02:43:22 +08:00
parent 113eb4b48d
commit 574e3457f6

View File

@ -98,8 +98,12 @@ namespace XNode {
// GetFields doesnt return inherited private fields, so walk through base types and pick those up // GetFields doesnt return inherited private fields, so walk through base types and pick those up
System.Type tempType = nodeType; System.Type tempType = nodeType;
while ((tempType = tempType.BaseType) != typeof(XNode.Node)) { while ((tempType = tempType.BaseType) != typeof(XNode.Node))
fieldInfo.AddRange(tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)); {
//只返回私有的,保护等其他的不需要
var fieldInfos = tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where(x=>x.IsPrivate);
fieldInfo.AddRange(fieldInfos);
} }
return fieldInfo; return fieldInfo;
} }