ParameterInfo.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // System.Reflection.ParameterInfo
  2. //
  3. // Sean MacIsaac ([email protected])
  4. //
  5. // (C) 2001 Ximian, Inc.
  6. using System.Reflection.Emit;
  7. namespace System.Reflection
  8. {
  9. [Serializable]
  10. public class ParameterInfo : ICustomAttributeProvider
  11. {
  12. protected Type ClassImpl;
  13. protected object DefaultValueImpl;
  14. protected MemberInfo MemberImpl;
  15. protected string NameImpl;
  16. protected int PositionImpl;
  17. protected ParameterAttributes AttrsImpl;
  18. protected ParameterInfo () {
  19. }
  20. internal ParameterInfo (ParameterBuilder pb, Type type, MemberInfo member, int position) {
  21. this.ClassImpl = type;
  22. this.MemberImpl = member;
  23. if (pb != null) {
  24. this.NameImpl = pb.Name;
  25. this.PositionImpl = pb.Position;
  26. this.AttrsImpl = (ParameterAttributes) pb.Attributes;
  27. } else {
  28. this.NameImpl = "";
  29. this.PositionImpl = position;
  30. this.AttrsImpl = ParameterAttributes.None;
  31. }
  32. }
  33. /* to build a ParameterInfo for the return type of a method */
  34. internal ParameterInfo (Type type, MemberInfo member) {
  35. this.ClassImpl = type;
  36. this.MemberImpl = member;
  37. this.NameImpl = "";
  38. this.PositionImpl = 0;
  39. this.AttrsImpl = ParameterAttributes.Retval;
  40. }
  41. public virtual Type ParameterType {
  42. get {return ClassImpl;}
  43. }
  44. public virtual ParameterAttributes Attributes {
  45. get {return AttrsImpl;}
  46. }
  47. public virtual object DefaultValue {
  48. get {return DefaultValueImpl;}
  49. }
  50. public bool IsIn {
  51. get {return (AttrsImpl & ParameterAttributes.In) != 0;}
  52. }
  53. public bool IsLcid {
  54. get {return (AttrsImpl & ParameterAttributes.Lcid) != 0;}
  55. }
  56. public bool IsOptional {
  57. get {return (AttrsImpl & ParameterAttributes.Optional) != 0;}
  58. }
  59. public bool IsOut {
  60. get {return (AttrsImpl & ParameterAttributes.Out) != 0;}
  61. }
  62. public bool IsRetval {
  63. get {return (AttrsImpl & ParameterAttributes.Retval) != 0;}
  64. }
  65. public virtual MemberInfo Member {
  66. get {return MemberImpl;}
  67. }
  68. public virtual string Name {
  69. get {return NameImpl;}
  70. }
  71. public virtual int Position {
  72. get {return PositionImpl;}
  73. }
  74. public virtual object[] GetCustomAttributes (bool inherit)
  75. {
  76. return MonoCustomAttrs.GetCustomAttributes (this, inherit);
  77. }
  78. public virtual object[] GetCustomAttributes (Type attributeType, bool inherit)
  79. {
  80. return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
  81. }
  82. public virtual bool IsDefined( Type attributeType, bool inherit) {
  83. return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
  84. }
  85. }
  86. }