Need help on custom TypeConverter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Kallal

    #1

    Need help on custom TypeConverter

    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
    -------------------------------------------

    Thanks in advance,

    Steve Kallal

  • Cor Ligthert

    #2
    Re: Need help on custom TypeConverter

    Steve,

    What should this TypeConverter do, now it does nothing,

    Cor


    Comment

    • Steve Kallal

      #3
      Re: Need help on custom TypeConverter

      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.

      "Cor Ligthert" wrote:
      [color=blue]
      > Steve,
      >
      > What should this TypeConverter do, now it does nothing,
      >
      > Cor
      >
      >
      >[/color]

      Comment

      • Cor Ligthert

        #4
        Re: Need help on custom TypeConverter

        Steve,

        Maybe can this sample from Tom help you.

        \\\Tom Shelton
        Private Function SerializeFontOb ject(ByVal fnt As Font) As String
        Dim bf As New BinaryFormatter
        Dim mem As New MemoryStream
        Try
        bf.Serialize(me m, fnt)
        Return Convert.ToBase6 4String(mem.ToA rray())
        Catch
        Return String.Empty
        Finally
        mem.Close()
        End Try
        End Function


        Private Function DeserializeFont Object(ByVal fnt As String) As Font
        Dim bf As New BinaryFormatter
        Dim mem As New MemoryStream(Co nvert.FromBase6 4String(fnt))
        Try
        Return DirectCast(bf.D eserialize(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


        Comment

        Working...