Last active
April 1, 2016 06:58
-
-
Save tkouba/8d128bc9ea14a5d2928e2b8d28af3901 to your computer and use it in GitHub Desktop.
ColorValueConverter for DevExpress XPO - save Color to database as Int32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ColorValueConverter : ValueConverter | |
{ | |
public override Type StorageType { get { return typeof(Int32); } } | |
public override object ConvertToStorageType(object value) | |
{ | |
if (!(value is Color)) return null; | |
return ((Color)value).ToArgb() & 0x00FFFFFF; | |
} | |
public override object ConvertFromStorageType(object value) | |
{ | |
if (!(value is Int32)) return null; | |
return Color.FromArgb((Int32)value | /* 0xFF000000 */ -16777216); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment