FindField() private method

private FindField ( string name, IKVM.Reflection.FieldSignature signature ) : IKVM.Reflection.FieldInfo
name string
signature IKVM.Reflection.FieldSignature
return IKVM.Reflection.FieldInfo
コード例 #1
0
		private static void AddNamedArgument(List<CustomAttributeNamedArgument> list, Type attributeType, string fieldName, Type valueType, object value)
		{
			// some fields are not available on the .NET Compact Framework version of DllImportAttribute/MarshalAsAttribute
			FieldInfo field = attributeType.FindField(fieldName, FieldSignature.Create(valueType, new CustomModifiers()));
			if (field != null)
			{
				list.Add(new CustomAttributeNamedArgument(field, new CustomAttributeTypedArgument(valueType, value)));
			}
		}
コード例 #2
0
		private static FieldInfo GetField(Module context, Type type, string name, Type fieldType)
		{
			Type org = type;
			for (; type != null && !type.__IsMissing; type = type.BaseType)
			{
				foreach (FieldInfo field in type.__GetDeclaredFields())
				{
					if (field.IsPublic && !field.IsStatic && field.Name == name)
					{
						return field;
					}
				}
			}
			// if the field is missing, we stick the missing field on the first missing base type
			if (type == null)
			{
				type = org;
			}
			FieldSignature sig = FieldSignature.Create(fieldType, new CustomModifiers());
			return type.FindField(name, sig)
				?? type.Module.universe.GetMissingFieldOrThrow(context, type, name, sig);
		}