I have created an application that allows users to capture information for entities based on a pre-defined template, which I create through a web interface.
So for instance I create a template and call it “Customer Template” with several properties like First Name, Last Name, Email address and I associate a “data type” to each property, which does not strictly map to a strongly typed type.
When the user then creates a new “Customer” a html form is generated with the appropriate properties / fields, which the user can provide and save.
The data types are called “Plain Text” or “Number” or “Currency” but do not map to a data type. What would be the best approach to associate a “number” to a strongly typed int, for instance, so that when I do operations on it that it is the correct type?
The number of “types” that the users will use are finite, maybe less than 10. Would I run into problems with a switch statement? Or is there another way?
I use c#.
I would use custom attributes to identify the CLR type mapped to your Form Types as such:
You can retrieve the FieldDataTypes’ attribute using reflection.