pencat
从明天起,关心粮食和蔬菜。我有一所房子,面朝大海,春暖花开
导航
首页
站内搜索
标签云
留言簿
« 网站被黑之后所想到的
构思随笔 »
2007-11-19 21:49:9
asp中的序列化与反序列化
这个方法可以把类的状态序列化,但是反序列化的时候要类的原型, 这点比较头疼. 下一步要解决的问题是如何序列化类原型. 难点在于如何在VB6中动态加载类. goole一圈都是.net和java下的实现方法. - -! serialize.asp
<% '-------------------------------------------' ' @title : de/serialize objects in vbscript ' ' @author: Peter Bucher ' ' @orgin : Switzerland ' ' ' ' @licence: use for free ' ' ' ' description: ' ' s_obj = string of the object name example: "myobject" ' ' obj = letter of the object name example: myobject ' '-------------------------------------------' %> <% '// Serialize Function Function Serialize(obj, s_obj) Dim i_counter, _ a_names, _ i_ubound a_names = Split(listPropertyNames(obj), ";next;") i_ubound = UBound(a_names) Dim a_session() Redim a_session(i_ubound, i_ubound) For i_counter = 0 To UBound(a_names) -1 a_session(i_counter, 0) = a_names(i_counter) a_session(i_counter, 1) = Eval(s_obj & "." & a_names(i_counter)) Next 'response.write a_session Session(s_obj) = a_session End Function %> <% '// DeSerialize Function Function DeSerialize(s_obj) Dim a_names_and_values, _ y_counter a_2 = Session(s_obj) For y_counter = 0 To UBound(a_2) -1 Execute(s_obj & "." & a_2(y_counter, 0) & " = """ & a_2(y_counter, 1) & """") Next End Function %> <% '// Test Class Class MyClass Dim m_MyProp Public Property Get MyProp MyProp = m_MyProp End Property Public Property Let MyProp(newText) m_MyProp = newText End Property End Class %>
test1.asp
<% Set c = New MyClass c.MyProp = "sdfasfasdfasd" Call Serialize(c, "c") set a = Server.CreateObject("Template.Test") a.fff(session("c")) %>
go on page 2
test2.asp
<% Set c = New MyClass Call DeSerialize("c") Response.Write c.myprop %>
go on page 1
Tags:
发布:pencat | 分类:开发随笔 | 评论:0 | 引用:0 | 浏览:
点击这里获取该日志的TrackBack引用地址
相关文章:
发表评论:
名称(*)
邮箱
网站链接
验证(*)
正文(*)(留言最长字数:1000)
记住我,下次回复时不用重新输入个人信息
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
日历
最新评论及回复
最近发表
Powered By
Z-Blog 1.8 Devo Build 80201
Copyright © 1998-2007 bigcomic.com All rights reserved.