FieldReference.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // Author:
  3. // Jb Evain (jbevain@gmail.com)
  4. //
  5. // Copyright (c) 2008 - 2015 Jb Evain
  6. // Copyright (c) 2008 - 2011 Novell, Inc.
  7. //
  8. // Licensed under the MIT/X11 license.
  9. //
  10. using System;
  11. namespace ILRuntime.Mono.Cecil {
  12. public class FieldReference : MemberReference {
  13. TypeReference field_type;
  14. public TypeReference FieldType {
  15. get { return field_type; }
  16. set { field_type = value; }
  17. }
  18. public override string FullName {
  19. get { return field_type.FullName + " " + MemberFullName (); }
  20. }
  21. public override bool ContainsGenericParameter {
  22. get { return field_type.ContainsGenericParameter || base.ContainsGenericParameter; }
  23. }
  24. internal FieldReference ()
  25. {
  26. this.token = new MetadataToken (TokenType.MemberRef);
  27. }
  28. public FieldReference (string name, TypeReference fieldType)
  29. : base (name)
  30. {
  31. Mixin.CheckType (fieldType, Mixin.Argument.fieldType);
  32. this.field_type = fieldType;
  33. this.token = new MetadataToken (TokenType.MemberRef);
  34. }
  35. public FieldReference (string name, TypeReference fieldType, TypeReference declaringType)
  36. : this (name, fieldType)
  37. {
  38. Mixin.CheckType (declaringType, Mixin.Argument.declaringType);
  39. this.DeclaringType = declaringType;
  40. }
  41. protected override IMemberDefinition ResolveDefinition ()
  42. {
  43. return this.Resolve ();
  44. }
  45. public new virtual FieldDefinition Resolve ()
  46. {
  47. var module = this.Module;
  48. if (module == null)
  49. throw new NotSupportedException ();
  50. return module.Resolve (this);
  51. }
  52. }
  53. }