Esempio n. 1
0
		public FieldReference ImportField (FieldReference field, IGenericContext context)
		{
			var declaring_type = ImportType (field.DeclaringType, context);

			return new FieldReference {
				Name = field.Name,
				DeclaringType = declaring_type,
				FieldType = ImportType (field.FieldType, context ?? declaring_type),
			};
		}
Esempio n. 2
0
		static FieldDefinition GetField (IAssemblyResolver resolver, TypeDefinition type, FieldReference reference)
		{
			while (type != null) {
				var field = GetField (type.Fields, reference);
				if (field != null)
					return field;

				if (type.BaseType == null)
					return null;

				type = Resolve (resolver, type.BaseType);
			}

			return null;
		}
Esempio n. 3
0
		static FieldDefinition GetField (IList<FieldDefinition> fields, FieldReference reference)
		{
			for (int i = 0; i < fields.Count; i++) {
				var field = fields [i];

				if (field.Name != reference.Name)
					continue;

				if (!AreSame (field.FieldType, reference.FieldType))
					continue;

				return field;
			}

			return null;
		}
Esempio n. 4
0
		public static FieldDefinition Resolve (IAssemblyResolver resolver, FieldReference field)
		{
			var type = Resolve (resolver, field.DeclaringType);
			if (type == null)
				return null;

			if (!type.HasFields)
				return null;

			return GetField (resolver, type, field);
		}