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