正在阅读:.Net进阶:实现Prototype设计模式.Net进阶:实现Prototype设计模式

2004-05-28 10:23 出处:CSDN 作者:guoyan19811021(翻译) 责任编辑:linjixiong


   Dim objBinFormatter As New BinaryFormatter

        Try

            objStream = File.Open("Empdata.bin", FileMode.Create)

            objBinFormatter.Serialize(objStream, Me)

            objStream.Close()

            objStream = File.Open("Empdata.bin", FileMode.Open)

            objEmpCopy = CType(objBinFormatter.Deserialize(objStream), CEmpData)

            objStream.Close()

            CreateDeepCopy = objEmpCopy

        Catch ex As Exception

            MsgBox(ex.ToString)

        End Try

    End Function

    Public Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData

        Dim intIndex As Integer

        Dim objEmp As CEmp

        info.AddValue("emp_count", ArrEmp.Count)

        For intIndex = 0 To ArrEmp.Count - 1

            objEmp = ArrEmp(intIndex)

            objEmp.GetObjectData(info, context, intIndex)

        Next

    End Sub

    Public Function GetEmpData() As String

        Dim intCount As Integer

        Dim strEmpData As String

        For intCount = 0 To ArrEmp.Count - 1

            strEmpData = strEmpData & CType(ArrEmp(intCount), CEmp).FName & Chr(9) & CType(ArrEmp(intCount), CEmp).LName & Chr(13)

        Next

        GetEmpData = strEmpData

     


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品