private IObjectPropertyCollection ParseObjectProperties(IParsingSourceStream sourceStream, ref string line) { IObjectPropertyCollection ObjectPropertyList = new ObjectPropertyCollection(); string HeaderLine = sourceStream.Line; if (HeaderLine != "properties") { throw new ParsingException(95, sourceStream, "'properties' expected."); } while (!sourceStream.EndOfStream) { sourceStream.ReadLine(); if (string.IsNullOrEmpty(sourceStream.Line)) { break; } IObjectProperty NewProperty = ParseProperty(sourceStream); foreach (IObjectProperty ObjectProperty in ObjectPropertyList) { if (ObjectProperty.NameSource.Name == NewProperty.NameSource.Name) { throw new ParsingException(96, sourceStream, $"Object already contains a property called '{NewProperty.NameSource.Name}'."); } } ObjectPropertyList.Add(NewProperty); } return(ObjectPropertyList); }
public override Term VisitObject(TVoid parameter, Term term, IObjectId id, ObjectPropertyCollection properties) { object value; if (this.TermManager.TryGetObject(term, out value)) { return(base.VisitObject(parameter, term, id, properties)); } else { TypeEx type; if (!this.TermManager.TryGetObjectType(term, out type)) { SafeDebug.Fail("cannet get object type"); } int index = types.Add(type); return(this.TermManager.Object(new SomeId(index), properties)); } }
internal Literacy(TypeInfo info, bool ignoreCase) { if (info == null) { throw new ArgumentNullException("info"); } TypeInfo = info; Type = info.Type; _CallNewObject = PreNewObject; Property = new ObjectPropertyCollection(ignoreCase); foreach (var p in Type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { if (p.GetIndexParameters().Length == 0) //排除索引器 { if (!Property.ContainsKey(p.Name)) { var a = new ObjectProperty(p); Property.Add(a); } } } ID = Interlocked.Increment(ref Sequence); UID = Guid.NewGuid(); TypeCodes = info.TypeCodes; }
/// <summary> 加载公开的静态的字段,参数hasNonPublic为true,则非公开的静态字段也一起加载 /// </summary> /// <param name="hasNonPublic">是否一起加载非公开的静态字段</param> void ILoadMember.StaticField(bool hasNonPublic) { if (Loaded(hasNonPublic ? 3 : 4)) { 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 (Field.ContainsKey(f.Name) == false) { Field.Add(new ObjectProperty(f)); } } Monitor.Exit(this); }
/// <summary> 加载公开的实例字段 /// </summary> void ILoadMember.PublicField() { if (Loaded(1)) { return; } if (Field == null) { Field = new ObjectPropertyCollection(Property.IgnoreCase); } const BindingFlags bf = BindingFlags.Public | BindingFlags.Instance; foreach (var f in Type.GetFields(bf)) { 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) { if (type == null) { throw new ArgumentNullException("type"); } Type = type; _CallNewObject = PreNewObject; Property = new ObjectPropertyCollection(ignoreCase); foreach (var p in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { if (p.GetIndexParameters().Length == 0) //排除索引器 { if (!Property.ContainsKey(p.Name)) { var a = new ObjectProperty(p); Property.Add(a); } } } }