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]);
                }
            }
        }
예제 #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];
            }
        }