Gadget,
Sorry probably not explained it that well.
I have made all my business objects, but the web site allows for users
to rename the properties. This is not done by recompiling code, i have
a table in my database that has a list of the classes and properties
stored as strings (ie. Company.Name). And then i have two fields
called Singular and plural so users can type the string that they want
to appear next to the property.
Example
If i had Company.Name stored in one field, the singular could be
"Company Name" and the plural "Company Names". On the website, a label
control would appear next to the value of the property.
Company Name = COMPANY NAME HERE
Does this make sense??
Yes, I think I understand. So the database row primary key is a combination
of the class name and the property name, and the rows in this table should
be created once after you have compiled your application, as they remain
static throughout a single version of your application because the classes
are obviously non-changing.
So presumably you only need to know the associated class and properties
when a form is being displayed. This means that during the Load event or
constructor you plan to look at all the labels on the screen and find the
associated values from the database?
What ties an input field on the form to a particular property of an object?
Are you using form data-binding? There has to be something that relates the
label associated with an input control to the business object and property
it is associated with, and there is not really any generic or magic way to
do this. If you are planning on using a DataGrid, and want to automatically
set the column names, then this is probably best done by defining a static
method and calling it, passing in the DataGrid instance and the class type.
A sensible way to handle discrete controls on a form might be to inherit
from a Label component, say to a 'PersonalizedLabel', add string properties
of "AppliesToClass" and "AppliesToProperty", then during the load event
have each lookup the new label value and set it in the Text property.
Also for performance make sure that during the application startup you load
the contents of your labels into a cache class (e.g. Dictionary<string,
LabelRowDetails>) so you can lookup controls on every form load without any
database access.
Might I also suggest that perhaps you should add another column denoting
the use of the class on the form, because if you use the same class in two
locations (e.g. On a customer form, where a field might be called "Name:",
and on an administration form where your customer might call it "Customer
Name:") then it would be nice to build in the option of 'switching' labels
for special circumstances. This might not happen, but for 30secs of work
now it might save you many hours later
Just a few thoughts and observations, and I don't know if I've missed the
point somewhere here
Cheers,
Gadget