private void EnsureFields()
 {
     if (_fields == null)
     {
         _fields = new List <ImportedField>();
         foreach (FieldDefinitionHandle fieldHandle in _typeDef.GetFields())
         {
             FieldDefinition fieldDef = Module.Reader.GetFieldDefinition(fieldHandle);
             ImportedField   field    = new ImportedField(Module, fieldDef, this);
             _fields.Add(field);
         }
     }
 }
        public ImportedField TryGetPublicStaticField(string name)
        {
            ImportedField result = null;

            EnsureFields();
            foreach (ImportedField field in _fields)
            {
                if (!field.IsPublic || !field.IsStatic)
                {
                    continue; // Is not public static
                }
                if (!string.Equals(name, field.Name))
                {
                    continue; // Name doesn't match
                }
                if (result != null)
                {
                    return(null); // Ambiguous match
                }
                result = field;
            }

            return(result);
        }
 private void EnsureFields()
 {
     if (_fields == null)
     {
         _fields = new List<ImportedField>();
         foreach (FieldDefinitionHandle fieldHandle in _typeDef.GetFields())
         {
             FieldDefinition fieldDef = Module.Reader.GetFieldDefinition(fieldHandle);
             ImportedField field = new ImportedField(Module, fieldDef, this);
             _fields.Add(field);
         }
     }
 }