我有一个如下对象
Public Class Item
Public Property Description As String
<XmlIgnore>
Public Property Picture As Bitmap = My.Resources.no_image
<XmlElement(ElementName:="Picture")>
<Browsable(False)>
Public Property _pic As String
Get
Return ImageToString(Me.Picture)
End Get
Set
Picture = StringToImage(Value)
End Set
End Property
Public Property Location As String
Public Property Price As Single
Public Property Status As String
End Class
该对象旨在显示在winforms中的DataGridView
中,但是我也希望能够使用XmlSerializer
将其序列化为XML。我实现了两个将位图转换为base64字符串并返回的函数。
我遇到麻烦的地方是想出一种方法来更改Bitmap类的序列化过程,因为它是不可继承的,并且上述解决方案没有达到预期的结果。
我该如何解决?