Exemplo n.º 1
0
        IEnumerable <FieldDef> GetPossibleFields(TypeDef type)
        {
            var typeToFields = new TypeDefDict <List <FieldDef> >();

            foreach (var field in type.Fields)
            {
                if (field.Attributes != FieldAttributes.Private)
                {
                    continue;
                }
                var fieldType = DotNetUtils.GetType(module, field.FieldSig.GetFieldType());
                if (fieldType == null)
                {
                    continue;
                }
                if (!CheckBaseType(fieldType))
                {
                    continue;
                }
                var list = typeToFields.Find(fieldType);
                if (list == null)
                {
                    typeToFields.Add(fieldType, list = new List <FieldDef>());
                }
                list.Add(field);
            }

            foreach (var list in typeToFields.GetValues())
            {
                if (list.Count == 1)
                {
                    yield return(list[0]);
                }
            }
        }
Exemplo n.º 2
0
		IEnumerable<FieldDef> GetPossibleFields(TypeDef type) {
			var typeToFields = new TypeDefDict<List<FieldDef>>();
			foreach (var field in type.Fields) {
				if (field.Attributes != FieldAttributes.Private)
					continue;
				var fieldType = DotNetUtils.GetType(module, field.FieldSig.GetFieldType());
				if (fieldType == null)
					continue;
				if (!CheckBaseType(fieldType))
					continue;
				var list = typeToFields.Find(fieldType);
				if (list == null)
					typeToFields.Add(fieldType, list = new List<FieldDef>());
				list.Add(field);
			}

			foreach (var list in typeToFields.GetValues()) {
				if (list.Count == 1)
					yield return list[0];
			}
		}