ParameterInfo.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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) {
  21. this.ClassImpl = type;
  22. this.MemberImpl = member;
  23. this.NameImpl = pb.Name;
  24. this.PositionImpl = pb.Position;
  25. this.AttrsImpl = (ParameterAttributes) pb.Attributes;
  26. }
  27. /* to build a ParameterInfo for the return type of a method */
  28. internal ParameterInfo (Type type, MemberInfo member) {
  29. this.ClassImpl = type;
  30. this.MemberImpl = member;
  31. this.NameImpl = "";
  32. this.PositionImpl = 0;
  33. this.AttrsImpl = ParameterAttributes.Retval;
  34. }
  35. public virtual Type ParameterType {
  36. get {return ClassImpl;}
  37. }
  38. public virtual ParameterAttributes Attributes {
  39. get {return AttrsImpl;}
  40. }
  41. public virtual object DefaultValue {
  42. get {return DefaultValueImpl;}
  43. }
  44. public bool IsIn {
  45. get {return (AttrsImpl & ParameterAttributes.In) != 0;}
  46. }
  47. public bool IsLcid {
  48. get {return (AttrsImpl & ParameterAttributes.Lcid) != 0;}
  49. }
  50. public bool IsOptional {
  51. get {return (AttrsImpl & ParameterAttributes.Optional) != 0;}
  52. }
  53. public bool IsOut {
  54. get {return (AttrsImpl & ParameterAttributes.Out) != 0;}
  55. }
  56. public bool IsRetval {
  57. get {return (AttrsImpl & ParameterAttributes.Retval) != 0;}
  58. }
  59. public virtual MemberInfo Member {
  60. get {return MemberImpl;}
  61. }
  62. public virtual string Name {
  63. get {return NameImpl;}
  64. }
  65. public virtual int Position {
  66. get {return PositionImpl;}
  67. }
  68. public virtual object[] GetCustomAttributes (bool inherit)
  69. {
  70. return MonoCustomAttrs.GetCustomAttributes (this, inherit);
  71. }
  72. public virtual object[] GetCustomAttributes (Type attributeType, bool inherit)
  73. {
  74. return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
  75. }
  76. public virtual bool IsDefined( Type attributeType, bool inherit) {
  77. return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
  78. }
  79. }
  80. }