/// <summary> /// Create the FieldRef equivalent to this FieldDef. If one does not /// exist then create it. /// </summary> /// <returns>FieldRef for this FieldDef</returns> public FieldRef MakeRefOf() { if (refOf != null) return refOf; ClassRef parRef = ((ClassDef)parent).MakeRefOf(); refOf = parRef.GetField(name); if (refOf == null) { Type refType; if (type is ClassDef) { refType = ((ClassDef)type).MakeRefOf(); } else { refType = type; } refOf = new FieldRef(parRef,name,refType); refOf.defOf = this; } return refOf; }
internal static void GetFieldRefs(PEReader buff, uint num, ClassRef parent) { for (int i=0; i < num; i++) { uint flags = buff.ReadUInt16(); string name = buff.GetString(); uint sigIx = buff.GetBlobIx(); if ((flags & (uint)FieldAttr.Public) == (uint)FieldAttr.Public) { if (parent.GetField(name) == null) { //Console.WriteLine(parent.NameString()); buff.currentClassScope = parent; FieldRef fRef = new FieldRef(parent,name,buff.GetFieldType(sigIx)); buff.currentClassScope = null; parent.AddToFieldList(fRef); } } } }
internal void AddField(FieldRef fld) { fields.Add(fld); fld.SetParent(this); }
/// <summary> /// Add a field to this class /// </summary> /// <param name="name">field name</param> /// <param name="fType">field type</param> /// <returns>a descriptor for this field</returns> public FieldRef AddField(string name, Type fType) { FieldRef fld = (FieldRef)FindField(name); if (fld != null) DescriptorError(fld); fld = new FieldRef(this,name,fType); fields.Add(fld); return fld; }
internal void AddToFieldList(FieldRef fld) { defaultClass.AddToFieldList(fld); }
/// <summary> /// Add a field to this scope. /// </summary> /// <param name="fld">The field to be added</param> public void AddField(FieldRef fld) { defaultClass.AddField(fld); }
internal static void ReadMember(PEReader buff, TableRow[] members) { for (int i=0; i < members.Length; i++) { uint parenIx = buff.GetCodedIndex(CIx.MemberRefParent); string memName = buff.GetString(); uint sigIx = buff.GetBlobIx(); if (buff.FirstBlobByte(sigIx) == Field.FieldTag) // got a field members[i] = new FieldRef(parenIx,memName,sigIx); else members[i] = new MethodRef(parenIx,memName,sigIx); } }