I have a VB class. It's big, so I'm posting a simplified example here:
Public Class ExampleClass
Public Property Foo As String
Public Property Bar As String
End Class
Suppose I have a text file like this:
foo,123
bar,456
And I want to read the file and populate the properties of my object accordingly.
Simplest way I can think of is to add a method with a case statement, like this:
Public Class ExampleClass
Public Property Foo As String
Public Property Bar As String
Public Sub SetProperty(prop As String, val As String)
Select Case prop
Case "Foo"
Foo = val
Case "Bar"
Bar = val
End Select
End Sub
End Class
But as my class will have around a hundred properties, so my SetProperty procedure is going to get big and boring to put together, and probably not be the most maintainable. Is there a better way to do this?
Before you tell me, I shouldn't structure my data this way, I know. However, this is a legacy database table that I have to live with. I'm updating the application with some new Entity Framework and LINQ code that will allow me to drop some very ugly stored procedures.
Thanks for your help.
James