Skip to content

Instantly share code, notes, and snippets.

@jacksonh
Created August 10, 2009 20:59
Show Gist options
  • Save jacksonh/165412 to your computer and use it in GitHub Desktop.
Save jacksonh/165412 to your computer and use it in GitHub Desktop.
Index: class/System.Windows/Mono/MoonlightTypeConverter.cs
===================================================================
--- class/System.Windows/Mono/MoonlightTypeConverter.cs (revision 139643)
+++ class/System.Windows/Mono/MoonlightTypeConverter.cs (working copy)
@@ -67,6 +67,9 @@
if (IsAssignableToIConvertible (sourceType) && IsAssignableToIConvertible (destinationType))
return true;
+ if (destinationType.IsEnum && Enum.GetUnderlyingType (destinationType).IsAssignableFrom (sourceType))
+ return true;
+
return base.CanConvertFrom (context, sourceType);
}
@@ -102,6 +105,9 @@
return new FontStretch ((FontStretchKind) Enum.Parse (typeof (FontStretchKind), str_val, true));
}
+ if (destinationType.IsEnum && Enum.IsDefined (destinationType, value))
+ return Enum.ToObject (destinationType, value);
+
if (value is Color && destinationType.IsAssignableFrom(typeof(SolidColorBrush))) {
return new SolidColorBrush ((Color)value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment