Results 1 to 12 of 12

Thread: [RESOLVED] [2005] persistence properties

Threaded View

  1. #1

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Resolved [RESOLVED] [2005] persistence properties

    Hi guys...

    im trying to implement a version manager in my base form. For that i made an object that inherits a collection... its working fine except the data entered is not saved... how to persist properties data ?

    this is my code
    VB Code:
    1. Imports System.Collections
    2.  
    3. Public Class Base
    4.  
    5.     ''' <summary>
    6.     ''' Gets or sets the version manager.
    7.     ''' </summary>
    8.     ''' <value>The version manager.</value>
    9.     Public Property VersionManager() As Versions
    10.         Get
    11.             VersionManager = mVersionManager
    12.         End Get
    13.         Set(ByVal value As Versions)
    14.             mVersionManager = value
    15.         End Set
    16.     End Property
    17.     Dim mVersionManager As Versions
    18.  
    19. End Class

    VB Code:
    1. Public Class Version
    2.  
    3.     ''' <summary>
    4.     ''' Gets or sets the form major version.
    5.     ''' </summary>
    6.     ''' <value>The form major version.</value>
    7.     Public Property FormMajorVersion() As Integer
    8.         Get
    9.             FormMajorVersion = mFormMajorVersion
    10.         End Get
    11.         Set(ByVal value As Integer)
    12.             mFormMajorVersion = value
    13.         End Set
    14.     End Property
    15.     Dim mFormMajorVersion As Integer
    16.  
    17.     ''' <summary>
    18.     ''' Gets or sets the form minor version.
    19.     ''' </summary>
    20.     ''' <value>The form minor version.</value>
    21.     Public Property FormMinorVersion() As Integer
    22.         Get
    23.             FormMinorVersion = mFormMinorVersion
    24.         End Get
    25.         Set(ByVal value As Integer)
    26.             mFormMinorVersion = value
    27.         End Set
    28.     End Property
    29.     Dim mFormMinorVersion As Integer
    30.  
    31.     ''' <summary>
    32.     ''' Gets or sets the username.
    33.     ''' </summary>
    34.     ''' <value>The username.</value>
    35.     Public Property Username() As String
    36.         Get
    37.             Username = mUsername
    38.         End Get
    39.         Set(ByVal value As String)
    40.             mUsername = value
    41.         End Set
    42.     End Property
    43.     Dim mUsername As String
    44.  
    45.     ''' <summary>
    46.     ''' Gets or sets the comments.
    47.     ''' </summary>
    48.     ''' <value>The comments.</value>
    49.     Public Property Comments() As String
    50.         Get
    51.             Comments = mComments
    52.         End Get
    53.         Set(ByVal value As String)
    54.             mComments = value
    55.         End Set
    56.     End Property
    57.     Dim mComments As String
    58.  
    59.     ''' <summary>
    60.     ''' Initializes a new instance of the <see cref="Version" /> class.
    61.     ''' </summary>
    62.     Public Sub New()
    63.     End Sub
    64.  
    65.     ''' <summary>
    66.     ''' Initializes a new instance of the <see cref="Version" /> class.
    67.     ''' </summary>
    68.     ''' <param name="majorVersion">The major version.</param>
    69.     ''' <param name="minorVersion">The minor version.</param>
    70.     ''' <param name="userName">Name of the user.</param>
    71.     ''' <param name="comments">The comments.</param>
    72.     Public Sub New(ByVal majorVersion As Integer, ByVal minorVersion As Integer, ByVal userName As String, Optional ByVal comments As String = Nothing)
    73.         mFormMajorVersion = majorVersion
    74.         mFormMinorVersion = minorVersion
    75.         mUsername = userName
    76.         mComments = comments
    77.     End Sub
    78.  
    79.     ''' <summary>
    80.     ''' Initializes a new instance of the <see cref="Version" /> class.
    81.     ''' </summary>
    82.     ''' <param name="e">The e.</param>
    83.     Public Sub New(ByVal e As Version)
    84.         mFormMajorVersion = e.FormMajorVersion
    85.         mFormMinorVersion = e.FormMinorVersion
    86.         mUsername = e.Username
    87.         mComments = e.Comments
    88.     End Sub
    89.  
    90. End Class

    VB Code:
    1. Public Class Versions
    2.     Inherits CollectionBase
    3.  
    4.     ''' <summary>
    5.     ''' Adds the specified e.
    6.     ''' </summary>
    7.     ''' <param name="e">The e.</param>
    8.     Public Sub add(ByVal e As Version)
    9.         List.Add(e)
    10.     End Sub
    11.  
    12.     ''' <summary>
    13.     ''' Deletes the specified e.
    14.     ''' </summary>
    15.     ''' <param name="e">The e.</param>
    16.     Public Sub delete(ByVal e As Version)
    17.         List.Remove(e)
    18.     End Sub
    19.  
    20.     ''' <summary>
    21.     ''' Deletes the specified index.
    22.     ''' </summary>
    23.     ''' <param name="index">The index.</param>
    24.     Public Sub delete(ByVal index As Integer)
    25.         If index < 0 Or index > List.Count - 1 Then
    26.             Throw New Exception("Invalid index to remove")
    27.         End If
    28.         List.RemoveAt(index)
    29.     End Sub
    30.  
    31.     ''' <summary>
    32.     ''' Gets the Item.
    33.     ''' </summary>
    34.     ''' <value>The search.</value>
    35.     Default Public Overridable ReadOnly Property Item(ByVal index As Integer) As Version
    36.         Get
    37.             Return CType(Me.List(index), Version)
    38.         End Get
    39.     End Property
    40.  
    41.     ''' <summary>
    42.     ''' Gets the search.
    43.     ''' </summary>
    44.     ''' <value>The search.</value>
    45.     Public ReadOnly Property Search(ByVal mjorVersion As Integer) As Version
    46.         Get
    47.             For Each e As Version In Me.List
    48.                 If e.FormMajorVersion = mjorVersion Then Return e
    49.             Next
    50.             Return Nothing
    51.         End Get
    52.     End Property
    53.  
    54. End Class

    thx in advance...
    Last edited by zuperman; Jan 22nd, 2007 at 07:17 PM. Reason: separate classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width