vbAccelerator - Contents of code file: Test_Person.clsVERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Person"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Implements IXMLPropertyBag
Private Type tPerson
bIsNew As Boolean
bIsDirty As Boolean
bIsDeleted As Boolean
sFirstName As String
sLastName As String
dBirthday As Date
End Type
Private m_tPerson As tPerson
Private m_colAddresses As Addresses
Private Sub Class_Initialize()
Set m_colAddresses = New Addresses
m_tPerson.bIsNew = True
End Sub
Private Sub IXMLPropertyBag_ReadProperties(ByVal PropertyBag As
vbalXMLPBag6.XMLPropertyBag)
Dim lCount As Long
Dim lIndex As Long
Dim cA As IXMLPropertyBag
Set m_colAddresses = New Addresses
With PropertyBag
m_tPerson.bIsDeleted = .ReadProperty("IsDeleted", False)
m_tPerson.bIsDirty = .ReadProperty("IsDirty", False)
m_tPerson.bIsNew = .ReadProperty("IsNew", False)
m_tPerson.sFirstName = .ReadProperty("FirstName")
m_tPerson.sLastName = .ReadProperty("LastName")
m_tPerson.dBirthday = .ReadProperty("Birthday")
lCount = .ReadProperty("AddressCount", 0)
For lIndex = 1 To lCount
.ReadProperty "Address" & lIndex, m_colAddresses.Add()
Next
' byte array test:
Dim b() As Byte
Dim v As Variant
v = .ReadProperty("SomeBytes")
If Not IsNull(v) Then
b = v
End If
End With
End Sub
Private Sub IXMLPropertyBag_WriteProperties(ByVal PropertyBag As
vbalXMLPBag6.XMLPropertyBag)
Dim lIndex As Long
With PropertyBag
.WriteProperty "IsDeleted", m_tPerson.bIsDeleted, False
.WriteProperty "IsDirty", m_tPerson.bIsDirty, False
.WriteProperty "IsNew", m_tPerson.bIsNew, False
.WriteProperty "Birthday", m_tPerson.dBirthday
.WriteProperty "FirstName", m_tPerson.sFirstName
.WriteProperty "LastName", m_tPerson.sLastName
.WriteProperty "AddressCount", m_colAddresses.Count
For lIndex = 1 To m_colAddresses.Count
.WriteProperty "Address" & lIndex, m_colAddresses.Item(lIndex)
Next
' Byte array test:
Dim b() As Byte, v As Variant
b = StrConv(m_tPerson.sFirstName, vbFromUnicode)
v = b
.WriteProperty "SomeBytes", v
End With
End Sub
Public Property Let FirstName(ByVal sValue As String)
m_tPerson.sFirstName = Trim$(sValue)
m_tPerson.bIsDirty = True
End Property
Public Property Get FirstName() As String
FirstName = m_tPerson.sFirstName
End Property
Public Property Let LastName(ByVal sValue As String)
m_tPerson.sLastName = Trim$(sValue)
m_tPerson.bIsDirty = True
End Property
Public Property Get LastName() As String
LastName = m_tPerson.sLastName
End Property
Public Property Let Birthday(ByVal dValue As Date)
m_tPerson.dBirthday = dValue
m_tPerson.bIsDirty = True
End Property
Public Property Get Birthday() As Date
Birthday = m_tPerson.dBirthday
End Property
Public Property Get IsDirty() As Boolean
IsDirty = m_tPerson.bIsDirty
End Property
Public Property Get IsNew() As Boolean
IsNew = m_tPerson.bIsNew
End Property
Public Property Get Addresses() As Addresses
Set Addresses = m_colAddresses
End Property
|
|