void ILoadMember.StaticField(bool hasNonPublic) { if (Loaded(3)) { return; } if (Field == null) { Field = new ObjectPropertyCollection(Property.IgnoreCase); } var bf = BindingFlags.Public | BindingFlags.Static; if (hasNonPublic) { bf |= BindingFlags.NonPublic; } foreach (var f in _Type.GetFields(bf)) { if (f.Name.Contains("<") == false && Field.ContainsKey(f.Name) == false) { Field.Add(new ObjectProperty(f)); } } Monitor.Exit(this); }
/// <summary> 初始化对象属性,字段访问组件,ignoreCase参数指示是否需要区分大小写 /// </summary> /// <param name="type">需快速访问的类型</param> /// <param name="ignoreCase">是否区分大小写(不区分大小写时应保证类中没有同名的(仅大小写不同的)属性或字段)</param> public Literacy(Type type, bool ignoreCase) { _Type = type; _CallNewObject = PreNewObject; Property = new ObjectPropertyCollection(ignoreCase); foreach (var p in type.GetProperties()) { if (p.GetIndexParameters().Length == 0)//排除索引器 { if (!Property.ContainsKey(p.Name)) { var a = new ObjectProperty(p); Property.Add(a); } } } }
void ILoadMember.NonPublicField() { if (Loaded(2)) { return; } if (Field == null) { Field = new ObjectPropertyCollection(Property.IgnoreCase); } var bf = BindingFlags.NonPublic | BindingFlags.Instance; foreach (var f in _Type.GetFields(bf)) { if (f.Name.Contains("<") == false) { Field.Add(new ObjectProperty(f)); } } Monitor.Exit(this); }