





















Public Shared Sub UpdateFrom(ByVal value As Object, ByVal values As NameValueCollection, ByVal objectPrefix As String)
Dim type As Type = value.GetType
Dim name As String = type.Name
Dim properties As PropertyInfo() = type.GetProperties
Dim info As PropertyInfo
For Each info In properties
Dim str2 As String = info.Name
If String.IsNullOrEmpty(objectPrefix) = False Then
str2 = (objectPrefix & str2)
End If
If (values.Item(str2) Is Nothing) Then
str2 = (name & "." & info.Name)
End If
If (values.Item(str2) Is Nothing) Then
str2 = (name & "_" & info.Name)
End If
If (Not values.Item(str2) Is Nothing) Then
Dim converter As TypeConverter = TypeDescriptor.GetConverter(info.PropertyType)
Dim obj2 As Object = values.Item(str2)
If Not converter.CanConvertFrom(GetType(String)) Then
Throw New FormatException(("No type converter available for type: " & info.PropertyType.ToString))
End If
obj2 = converter.ConvertFrom(values.Item(str2))
info.SetValue(value, obj2, Nothing)
End If
Next
End Sub
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。