一个ASP创建动态对象的工厂类(类似PHP的stdClas(7)
For i = 0 To m_objProperties.Count - 1
strPrivateName = "m_var" & Keys(i)
init = init & strPrivateName & "=""" & _
Replace(CStr(Items(i)(0)), """", """""") & """:"
pstr = pstr & "Private " & strPrivateName & " : "
strAvailableKeys = strAvailableKeys & Keys(i) & ","
If CInt(Items(i)(1)) > 0 Then ' ReadOnly
pstr = pstr & getReadOnlyCode(Keys(i))
ElseIf CInt(Items(i)(1)) < 0 Then ' WriteOnly
pstr = pstr & getWriteOnlyCode(Keys(i))
Else ' AccessAll
pstr = pstr & getReadOnlyCode(Keys(i)) & _
getWriteOnlyCode(Keys(i))
End If
Next
init = init & "m_strAvailableKeys = Replace(""," & _
strAvailableKeys & """, "" "", """") : "
Dim hasstmt
hasstmt = "Private m_strAvailableKeys : " & _
"Public Function hasattr_(ByVal key) : " & _
"hasattr_ = CBool(InStr(m_strAvailableKeys," & _
" "","" & key & "","") > 0) : " & _
"End Function : " & _
"Public Function getattr_(ByVal key, ByVal defaultValue) : " & _
"If hasattr_(key) Then : getattr_ = Eval(key) : " & _
内容版权声明:除非注明,否则皆为本站原创文章。