1 Star 0 Fork 2

yohaa0/tkinter-designer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
clsSerialization.cls 3.19 KB
一键复制 编辑 原始数据 按行查看 历史
cdhigh 提交于 2012-10-21 20:50 . v1.2
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsSerialization"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
'对象持续化类
Private mInnerArray() As String
Private mInnerArrayItems As Long
Private mInnerArrayCur As Long
'设置要解码的字符串
Public Property Let SerialString(newStr As String)
ResetStrArray
mInnerArray = Split(newStr, vbCrLf)
mInnerArrayItems = UBound(mInnerArray) + 1
mInnerArrayCur = 0
End Property
Public Property Get SerialString() As String
If mInnerArrayItems > 0 Then
SerialString = Join(mInnerArray, vbCrLf)
Else
SerialString = ""
End If
End Property
Public Sub Serializer(ParamArray vObjs() As Variant)
Dim i As Long
For i = LBound(vObjs) To UBound(vObjs)
Dim tType As String
tType = GetType(vObjs(i))
SaveData tType 'Save Type
Select Case tType
Case "Object"
SaveData TypeName(vObjs(i))
vObjs(i).Serializer Me
Case "Variant"
'Data = TypeName(vObjs(i))
SaveData vObjs(i)
Case "Nothing"
'Do Nothing
End Select
Next i
End Sub
Public Sub Deserializer(ParamArray vObjs() As Variant)
Dim i As Long, tType As String
For i = LBound(vObjs) To UBound(vObjs)
Dim Classification As String
Classification = GetData()
Select Case Classification
Case "Object"
tType = GetData()
vObjs(i).Deserializer Me
Case "Variant"
vObjs(i) = GetData()
Case "Nothing"
End Select
Next i
End Sub
Private Function GetType(vObj As Variant) As String
If IsObject(vObj) = True Then
GetType = "Object"
Exit Function
End If
If TypeName(vObj) = "Nothing" Then
GetType = "Nothing"
Exit Function
End If
If GetType = "" Then
GetType = "Variant"
Exit Function
End If
End Function
Private Sub Class_Initialize()
ResetStrArray
End Sub
Private Sub Class_Terminate()
ResetStrArray
End Sub
Private Function GetData() As Variant
GetData = GetOneInnerString
End Function
Private Sub SaveData(vData As Variant)
AppendInnerString CStr(vData)
End Sub
Private Function GetOneInnerString() As String
If mInnerArrayCur < mInnerArrayItems Then
GetOneInnerString = mInnerArray(mInnerArrayCur)
mInnerArrayCur = mInnerArrayCur + 1
End If
End Function
Private Sub AppendInnerString(ByVal newStr As String)
ReDim Preserve mInnerArray(mInnerArrayItems) As String
mInnerArray(mInnerArrayItems) = newStr
mInnerArrayItems = mInnerArrayItems + 1
End Sub
Private Sub ResetStrArray()
mInnerArrayItems = 0
mInnerArrayCur = 0
Erase mInnerArray
End Sub
Public Sub Reset()
ResetStrArray
End Sub
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yohaa0/tkinter-designer.git
git@gitee.com:yohaa0/tkinter-designer.git
yohaa0
tkinter-designer
tkinter-designer
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385