Need help on custom TypeConverter

G

Guest

I am trying to write a TypeConverter for a simple custom class that stores
four boolean properties.

Here is the sample code:

-------------------------------------------

Public Class UserPermissions
Private mCanUserRead As Boolean
Private mCanUserUpdate As Boolean
Private mCanUserAdd As Boolean
Private mCanUserDelete As Boolean
Private mViewID As Long

Public Property CanUserRead() As Boolean
Get
Return mCanUserRead
End Get
Set(ByVal Value As Boolean)
mCanUserRead = Value
End Set
End Property

Public Property CanUserUpdate() As Boolean
Get
Return mCanUserUpdate
End Get
Set(ByVal Value As Boolean)
mCanUserUpdate = Value
End Set
End Property

Public Property CanUserAdd() As Boolean
Get
Return mCanUserAdd
End Get
Set(ByVal Value As Boolean)
mCanUserAdd = Value
End Set
End Property

Public Property CanUserDelete() As Boolean
Get
Return mCanUserDelete
End Get
Set(ByVal Value As Boolean)
mCanUserDelete = Value
End Set
End Property

Public WriteOnly Property ViewID() As Long
Set(ByVal Value As Long)
mViewID = Value
End Set
End Property

Public Sub Load()
....
End Sub
 
G

Guest

I should be able to let me store in object in ViewState for ASP .NET. I
cannot do it now because it is not serializable.
 
C

Cor Ligthert

Steve,

Maybe can this sample from Tom help you.

\\\Tom Shelton
Private Function SerializeFontObject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(mem, fnt)
Return Convert.ToBase64String(mem.ToArray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function


Private Function DeserializeFontObject(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Convert.FromBase64String(fnt))
Try
Return DirectCast(bf.Deserialize(mem), Font)
Finally
If Not mem Is Nothing Then
mem.Close()
End If
End Try
End Function


I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top