public static bool AreMultipleAllowed (Type attr_type)
{
+ if (!(attr_type is TypeBuilder)) {
+ System.Attribute [] attrs = System.Attribute.GetCustomAttributes (attr_type);
+
+ foreach (System.Attribute tmp in attrs)
+ if (tmp is AttributeUsageAttribute)
+ return ((AttributeUsageAttribute) tmp).AllowMultiple;
+
+ return false;
+ }
+
if (attr_to_allowmult == null)
return false;
return (MethodInfo) pair.Second;
} else
- return ei.GetAddMethod ();
+ return ei.GetRemoveMethod ();
}
static Hashtable priv_fields_events;
// This is a custom version of Convert.ChangeType() which works
// with the TypeBuilder defined types when compiling corlib.
- public static object ChangeType (object value, Type conversionType)
+ public static object ChangeType (object value, Type conversionType, out bool error)
{
- if (!(value is IConvertible))
- throw new ArgumentException ();
-
+ if (!(value is IConvertible)){
+ error = true;
+ return null;
+ }
+
IConvertible convertValue = (IConvertible) value;
CultureInfo ci = CultureInfo.CurrentCulture;
NumberFormatInfo provider = ci.NumberFormat;
// the system type itself. You cannot use Type.GetTypeCode()
// on such a type - it'd always return TypeCode.Object.
//
+ error = false;
if (conversionType.Equals (typeof (Boolean)))
return (object)(convertValue.ToBoolean (provider));
else if (conversionType.Equals (typeof (Byte)))
else if (conversionType.Equals (typeof (Object)))
return (object)(value);
else
- throw new InvalidCastException ();
+ error = true;
+ return null;
}
//