diff options
Diffstat (limited to 'src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs')
-rw-r--r-- | src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs | 130 |
1 files changed, 69 insertions, 61 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs index 7c4ed9dc0f..6dbcba251f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs @@ -12,8 +12,9 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - + +namespace System.Reflection.Emit +{ using System; using System.Reflection; using CultureInfo = System.Globalization.CultureInfo; @@ -25,30 +26,29 @@ namespace System.Reflection.Emit { // method will return a new PropertyBuilder to a client. // public sealed class PropertyBuilder : PropertyInfo - { - + { // Make a private constructor so these cannot be constructed externally. - private PropertyBuilder() {} - + private PropertyBuilder() { } + // Constructs a PropertyBuilder. // internal PropertyBuilder( - ModuleBuilder mod, // the module containing this PropertyBuilder - String name, // property name - SignatureHelper sig, // property signature descriptor info - PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc - Type returnType, // return type of the property. - PropertyToken prToken, // the metadata token for this property - TypeBuilder containingType) // the containing type + ModuleBuilder mod, // the module containing this PropertyBuilder + String name, // property name + SignatureHelper sig, // property signature descriptor info + PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc + Type returnType, // return type of the property. + PropertyToken prToken, // the metadata token for this property + TypeBuilder containingType) // the containing type { if (name == null) throw new ArgumentNullException(nameof(name)); if (name.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); if (name[0] == '\0') - throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(name)); + throw new ArgumentException(SR.Argument_IllegalName, nameof(name)); Contract.EndContractBlock(); - + m_name = name; m_moduleBuilder = mod; m_signature = sig; @@ -58,32 +58,32 @@ namespace System.Reflection.Emit { m_tkProperty = prToken.Token; m_containingType = containingType; } - + //************************************************ // Set the default value of the Property //************************************************ - public void SetConstant(Object defaultValue) + public void SetConstant(Object defaultValue) { m_containingType.ThrowIfCreated(); - + TypeBuilder.SetConstantValue( m_moduleBuilder, m_prToken.Token, m_returnType, defaultValue); } - + // Return the Token for this property within the TypeBuilder that the // property is defined within. public PropertyToken PropertyToken { - get {return m_prToken;} + get { return m_prToken; } } - + public override Module Module { - get + get { return m_containingType.Module; } @@ -102,25 +102,25 @@ namespace System.Reflection.Emit { m_prToken.Token, semantics, mdBuilder.GetToken().Token); - } + } public void SetGetMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Getter); m_getMethod = mdBuilder; } - + public void SetSetMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Setter); - m_setMethod = mdBuilder; + m_setMethod = mdBuilder; } public void AddOtherMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Other); } - + // Use this function if client decides to form the custom attribute blob themselves public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) @@ -129,7 +129,7 @@ namespace System.Reflection.Emit { throw new ArgumentNullException(nameof(con)); if (binaryAttribute == null) throw new ArgumentNullException(nameof(binaryAttribute)); - + m_containingType.ThrowIfCreated(); TypeBuilder.DefineCustomAttribute( m_moduleBuilder, @@ -151,29 +151,29 @@ namespace System.Reflection.Emit { } // Not supported functions in dynamic module. - public override Object GetValue(Object obj,Object[] index) + public override Object GetValue(Object obj, Object[] index) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Object GetValue(Object obj,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture) + public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj,Object value,Object[] index) + public override void SetValue(Object obj, Object value, Object[] index) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj,Object value,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture) + public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodInfo[] GetAccessors(bool nonPublic) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodInfo GetGetMethod(bool nonPublic) @@ -198,61 +198,69 @@ namespace System.Reflection.Emit { public override ParameterInfo[] GetIndexParameters() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Type PropertyType { + public override Type PropertyType + { get { return m_returnType; } } - public override PropertyAttributes Attributes { - get { return m_attributes;} + public override PropertyAttributes Attributes + { + get { return m_attributes; } } - public override bool CanRead { - get { if (m_getMethod != null) return true; else return false; } } + public override bool CanRead + { + get { if (m_getMethod != null) return true; else return false; } + } - public override bool CanWrite { + public override bool CanWrite + { get { if (m_setMethod != null) return true; else return false; } } public override Object[] GetCustomAttributes(bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override bool IsDefined (Type attributeType, bool inherit) + public override bool IsDefined(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override String Name { + public override String Name + { get { return m_name; } } - public override Type DeclaringType { + public override Type DeclaringType + { get { return m_containingType; } } - public override Type ReflectedType { + public override Type ReflectedType + { get { return m_containingType; } } // These are package private so that TypeBuilder can access them. - private String m_name; // The name of the property - private PropertyToken m_prToken; // The token of this property - private int m_tkProperty; - private ModuleBuilder m_moduleBuilder; - private SignatureHelper m_signature; - private PropertyAttributes m_attributes; // property's attribute flags - private Type m_returnType; // property's return type - private MethodInfo m_getMethod; - private MethodInfo m_setMethod; - private TypeBuilder m_containingType; + private String m_name; // The name of the property + private PropertyToken m_prToken; // The token of this property + private int m_tkProperty; + private ModuleBuilder m_moduleBuilder; + private SignatureHelper m_signature; + private PropertyAttributes m_attributes; // property's attribute flags + private Type m_returnType; // property's return type + private MethodInfo m_getMethod; + private MethodInfo m_setMethod; + private TypeBuilder m_containingType; } } |