From 574e3457f639c20044ac23ec972738e89a251d3a Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 22 Sep 2019 02:43:22 +0800 Subject: [PATCH] =?UTF-8?q?!B=20=E6=B2=A1=E6=9C=89=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4=E5=92=8C=E5=86=85=E9=83=A8=E7=AD=89=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5,=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=87=BA=E7=8E=B0=E5=A4=9A=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/NodeDataCache.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Scripts/NodeDataCache.cs b/Scripts/NodeDataCache.cs index 02e35a1..886f128 100644 --- a/Scripts/NodeDataCache.cs +++ b/Scripts/NodeDataCache.cs @@ -98,8 +98,12 @@ namespace XNode { // GetFields doesnt return inherited private fields, so walk through base types and pick those up System.Type tempType = nodeType; - while ((tempType = tempType.BaseType) != typeof(XNode.Node)) { - fieldInfo.AddRange(tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)); + while ((tempType = tempType.BaseType) != typeof(XNode.Node)) + { + //只返回私有的,保护等其他的不需要 + var fieldInfos = tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where(x=>x.IsPrivate); + + fieldInfo.AddRange(fieldInfos); } return fieldInfo; }