Reputation: 1806
I have a modified Panel control in Winforms. It will save the content of all controls that are on it to a file. An example control could be: "CheckBox_OptionA"
Now I want to be able to do this: bool optiona = MyForm.MyAutoSavePanel.OptionA;
I know that I could make an indexer for this, but I want to retain the compile time type-safety.
Is there a way to get those fields generated by visual studio with the correct type? I could easily get the needed type and all other information that is required.
Upvotes: 1
Views: 384
Reputation: 2445
There are two Microsoft technologies you could look at to generate code files for you: CodeDOM and T4. CodeDOM is object model based so you would write an application in C# that would build up an object model based on some input and then output one or more code files. T4 is newer and based on text templating of code (or any other) files, which can be quicker to write, so look at that first.
Upvotes: 1