Example #1
0
        public override void SetValue(Object obj, Object value, Object[] index)
        {
            MethodInfo setter =
                ClrHelpers.GetSemantics(privateData,
                                        MethodSemanticsAttributes.Setter,
                                        true);

            if (setter == null)
            {
                throw new ArgumentException
                          (_("Reflection_NoPropertySet"));
            }
            Object[] parameters;
            if (index == null)
            {
                parameters    = new Object [1];
                parameters[0] = value;
            }
            else
            {
                parameters = new Object [index.Length + 1];
                Array.Copy(index, parameters, index.Length);
                parameters[index.Length] = value;
            }
            setter.Invoke(obj, BindingFlags.Default,
                          Type.DefaultBinder, parameters, null);
        }
Example #2
0
        // Get the index parameters for this property.
        public override ParameterInfo[] GetIndexParameters()
        {
            MethodInfo method =
                ClrHelpers.GetSemantics(privateData,
                                        MethodSemanticsAttributes.Getter,
                                        true);

            if (method != null)
            {
                return(method.GetParameters());
            }
            method =
                ClrHelpers.GetSemantics(privateData,
                                        MethodSemanticsAttributes.Setter,
                                        true);
            if (method != null)
            {
                ParameterInfo[] parameters = method.GetParameters();
                ParameterInfo[] newParams;
                if (parameters != null && parameters.Length >= 1)
                {
                    newParams = new ParameterInfo [parameters.Length - 1];
                    Array.Copy(parameters, newParams, newParams.Length);
                    return(newParams);
                }
            }
            throw new MethodAccessException
                      (_("Reflection_NoPropertyAccess"));
        }
Example #3
0
        // Get an array of all accessor methods on this property.
        public override MethodInfo[] GetAccessors(bool nonPublic)
        {
            MethodInfo getter =
                ClrHelpers.GetSemantics(privateData,
                                        MethodSemanticsAttributes.Getter,
                                        nonPublic);
            MethodInfo setter =
                ClrHelpers.GetSemantics(privateData,
                                        MethodSemanticsAttributes.Setter,
                                        nonPublic);
            MethodInfo other =
                ClrHelpers.GetSemantics(privateData,
                                        MethodSemanticsAttributes.Other,
                                        nonPublic);
            int size = ((getter != null) ? 1 : 0) +
                       ((setter != null) ? 1 : 0) +
                       ((other != null) ? 1 : 0);

            MethodInfo[] array = new MethodInfo [size];
            int          posn  = 0;

            if (getter != null)
            {
                array[posn++] = getter;
            }
            if (setter != null)
            {
                array[posn++] = setter;
            }
            if (other != null)
            {
                array[posn++] = other;
            }
            return(array);
        }
Example #4
0
 // Get the add method for this event.
 public override MethodInfo GetAddMethod(bool nonPublic)
 {
     return(ClrHelpers.GetSemantics
                (privateData,
                MethodSemanticsAttributes.AddOn,
                nonPublic));
 }
Example #5
0
        public override Object GetValue(Object obj, Object[] index)
        {
            MethodInfo getter =
                ClrHelpers.GetSemantics(privateData,
                                        MethodSemanticsAttributes.Getter,
                                        true);

            if (getter == null)
            {
                throw new ArgumentException
                          (_("Reflection_NoPropertyGet"));
            }
            return(getter.Invoke(obj, BindingFlags.Default,
                                 Type.DefaultBinder, index, null));
        }
Example #6
0
        // Get the parameters for this constructor.
        public override ParameterInfo[] GetParameters()
        {
            if (parameters != null)
            {
                return(parameters);
            }
            int numParams = ClrHelpers.GetNumParameters(privateData);
            int param;

            parameters = new ParameterInfo [numParams];
            for (param = 0; param < numParams; ++param)
            {
                parameters[param] =
                    ClrHelpers.GetParameterInfo(this, this, param + 1);
            }
            return(parameters);
        }
Example #7
0
        // Convert the constructor name into a string.
        public override String ToString()
        {
            StringBuilder builder   = new StringBuilder();
            int           numParams = ClrHelpers.GetNumParameters(privateData);
            int           param;
            ParameterInfo paramInfo;

            builder.Append("Void ");
            builder.Append(Name);
            builder.Append('(');
            for (param = 0; param < numParams; ++param)
            {
                if (param > 0)
                {
                    builder.Append(", ");
                }
                paramInfo = ClrHelpers.GetParameterInfo
                                (this, this, param + 1);
                builder.Append(paramInfo.ParameterType.Name);
            }
            builder.Append(')');
            return(builder.ToString());
        }
Example #8
0
 // Internal interface used when ICustomAttributeProvider
 // is declared as private in ParameterInfo.
 internal override Object[] ClrGetCustomAttributes(bool inherit)
 {
     return(ClrHelpers.GetCustomAttributes(this, inherit));
 }
Example #9
0
 // Determine if custom attributes are defined for this parameter.
 public override bool IsDefined(Type type, bool inherit)
 {
     return(ClrHelpers.IsDefined(this, type, inherit));
 }
Example #10
0
 public override Object[] GetCustomAttributes(Type type, bool inherit)
 {
     return(ClrHelpers.GetCustomAttributes(this, type, inherit));
 }
Example #11
0
 internal override bool ClrIsDefined(Type type, bool inherit)
 {
     return(ClrHelpers.IsDefined(this, type, inherit));
 }
Example #12
0
 // Get the method implementation flags.
 public override MethodImplAttributes GetMethodImplementationFlags()
 {
     return(ClrHelpers.GetImplAttrs(privateData));
 }
Example #13
0
 // Determine if custom attributes are associated with this assembly.
 bool ICustomAttributeProvider.IsDefined(Type type, bool inherit)
 {
     return(ClrHelpers.IsDefined(this, type, inherit));
 }
Example #14
0
 Object[] ICustomAttributeProvider.GetCustomAttributes
     (Type type, bool inherit)
 {
     return(ClrHelpers.GetCustomAttributes(this, type, inherit));
 }
Example #15
0
 // Determine if custom attributes are associated with this assembly.
 public virtual bool IsDefined(Type type, bool inherit)
 {
     return(ClrHelpers.IsDefined(this, type, inherit));
 }
Example #16
0
 // Get the custom attributes associated with this assembly.
 public virtual Object[] GetCustomAttributes(bool inherit)
 {
     return(ClrHelpers.GetCustomAttributes(this, inherit));
 }