3 // System.Reflection.Emit/PropertyBuilder.cs
6 // Paolo Molaro (lupus@ximian.com)
8 // (C) 2001 Ximian, Inc. http://www.ximian.com
12 using System.Reflection;
13 using System.Reflection.Emit;
14 using System.Globalization;
15 using System.Runtime.CompilerServices;
17 namespace System.Reflection.Emit {
18 public sealed class PropertyBuilder : PropertyInfo {
19 private PropertyAttributes attrs;
22 private Type[] parameters;
23 private object def_value;
24 private MethodBuilder set_method;
25 private MethodBuilder get_method;
26 private int table_idx = 0;
27 internal TypeBuilder typeb;
29 internal PropertyBuilder (TypeBuilder tb, string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) {
31 this.attrs = attributes;
32 this.type = returnType;
33 if (parameterTypes != null) {
34 this.parameters = new Type [parameterTypes.Length];
35 System.Array.Copy (parameterTypes, this.parameters, this.parameters.Length);
38 table_idx = tb.get_next_table_index (0x17, true);
41 public override PropertyAttributes Attributes {
44 public override bool CanRead {
45 get {return get_method != null;}
47 public override bool CanWrite {
48 get {return set_method != null;}
50 public override Type DeclaringType {
53 public override string Name {
56 public PropertyToken PropertyToken {
57 get {return new PropertyToken ();}
59 public override Type PropertyType {
62 public override Type ReflectedType {
65 public void AddOtherMethod( MethodBuilder mdBuilder) {
67 public override MethodInfo[] GetAccessors( bool nonPublic) {
70 public override object[] GetCustomAttributes(bool inherit) {
73 public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
76 public override MethodInfo GetGetMethod( bool nonPublic) {
79 public override ParameterInfo[] GetIndexParameters() {
82 public override MethodInfo GetSetMethod( bool nonPublic) {
85 public override object GetValue(object obj, object[] index) {
88 public override object GetValue( object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
91 public override bool IsDefined( Type attributeType, bool inherit) {
94 public void SetConstant( object defaultValue) {
95 def_value = defaultValue;
97 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
99 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
101 public void SetGetMethod( MethodBuilder mdBuilder) {
102 get_method = mdBuilder;
104 public void SetSetMethod( MethodBuilder mdBuilder) {
105 set_method = mdBuilder;
107 public override void SetValue( object obj, object value, object[] index) {
109 public override void SetValue( object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {