/// <summary> /// Finds fields /// </summary> /// <param name="name">Field name</param> /// <returns></returns> public IEnumerable <CorField> FindFields(string name, bool checkBaseClasses = true) { var mdi = Module?.GetMetaDataInterface <IMetaDataImport>(); foreach (var fdToken in MDAPI.GetFieldTokens(mdi, token)) { if (MDAPI.GetFieldName(mdi, fdToken) == name) { yield return(new CorField(this, fdToken)); } } if (checkBaseClasses) { var type = GetParameterizedType(CorElementType.Class); if (type != null) { type = type.Base; } if (type != null) { foreach (var func in type.FindFields(name, checkBaseClasses)) { yield return(func); } } } }
/// <summary> /// Finds fields /// </summary> /// <returns></returns> public IEnumerable <CorField> FindFields(bool checkBaseClasses = true) { for (var type = this; type != null; type = type.Base) { if (!checkBaseClasses && (object)this != (object)type) { break; } if (!type.HasClass) { continue; } var cls = type.Class; if (cls == null) { continue; } var mod = cls.Module; var mdi = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>(); foreach (var fdToken in MDAPI.GetFieldTokens(mdi, cls.Token)) { yield return(new CorField(cls, fdToken)); } } }
void InitFields_NoLock() { var mdi = readerModule.MetaDataImport; uint token = OriginalToken.Raw; fieldRidToFieldOffset = CalculateFieldOffsets(); var fds = fields; if (fds != null) { fds.Clear(); } var itemTokens = MDAPI.GetFieldTokens(mdi, token); var newItems = new MemberInfo <CorFieldDef> [itemTokens.Length]; for (int i = 0; i < itemTokens.Length; i++) { uint itemRid = itemTokens[i] & 0x00FFFFFF; newItems[i] = readerModule.Register(new CorFieldDef(readerModule, itemRid, this), cmd => cmd.Initialize()); } fields = new LazyList <FieldDef>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item); }
public static IEnumerable <CorFieldInfo> GetFieldInfos(IMetaDataImport mdi, uint token) { var fdTokens = MDAPI.GetFieldTokens(mdi, token); foreach (var fdToken in fdTokens) { var info = ReadFieldInfo(mdi, fdToken, null); Debug.Assert(info != null); if (info != null) { yield return(info); } } }
public static List <TokenAndName> GetFields(IMetaDataImport mdi, uint token) { var fdTokens = MDAPI.GetFieldTokens(mdi, token); var list = new List <TokenAndName>(fdTokens.Length); foreach (var fdToken in fdTokens) { var name = MDAPI.GetFieldName(mdi, fdToken); if (name == null) { continue; } list.Add(new TokenAndName(name, fdToken)); } return(list); }
DmdFieldInfo[] ReadDeclaredFields_COMThread(DmdType declaringType, DmdType reflectedType) { reader.Dispatcher.VerifyAccess(); var tokens = MDAPI.GetFieldTokens(reader.MetaDataImport, (uint)MetadataToken); if (tokens.Length == 0) { return(Array.Empty <DmdFieldInfo>()); } var fields = new DmdFieldInfo[tokens.Length]; for (int i = 0; i < fields.Length; i++) { uint rid = tokens[i] & 0x00FFFFFF; fields[i] = reader.CreateFieldDef_COMThread(rid, declaringType, reflectedType); } return(fields); }
public static IEnumerable <CorFieldInfo> GetFieldInfos(CorType type, bool checkBaseClasses = true) { for (; type != null; type = type.Base) { var cls = type.Class; var mdi = cls?.Module?.GetMetaDataInterface <IMetaDataImport>(); var fdTokens = MDAPI.GetFieldTokens(mdi, cls?.Token ?? 0); foreach (var fdToken in fdTokens) { var info = ReadFieldInfo(mdi, fdToken, type); Debug.Assert(info != null); if (info != null) { yield return(info); } } if (!checkBaseClasses) { break; } } }