Well, you could use the CodeDom or whatever to create such a type on
the fly - but what would be the benefit? What are you actually going to
do with this type afterwards? Why does it have to be an actual type,
rather than just being a set or map?
OK, here's what I am trying to do. I am writing a dialogue system. In
its present form it will allow a user to get information on train
departure and arrival times in a kiosk-like setting, using both speech
and a touch screen for input and output. There is one controlling
module, which starts up all the other modules (class libraries) that
make up the system. The controlling module reads a configuration file
to determine what classes to instantiate and in what modules they can
be found and then uses Assembly.LoadFrom, Assembly.GetTypes and
Activator.CreateInstance to do so. All communication between the
modules is done through events. These events and methods to raise them
are defined in a single central module that all other modules must
reference.
This all works pretty well and it's very easy to add new modules,
replace existing ones, and so on. Now I want to make this
infrastructure more general by also putting the events - which
basically define the functionality of the system - in a configuration
file. It would then be a snap to add new events, or use a completely
different set of events, without having to recompile anything.
So, I am thinking of having just one event, something like:
public delegate void EventHandlerKiosk( Object sender, EKioskEvents
kioskEvent, object obj );
public static event EventHandlerKiosk eventKiosk ;
The event would be raised by calling this method:
public static void RaiseEventKiosk( object sender, EKioskEvents
kioskEvent, object objKiosk ){
if( eventKiosk != null )
eventKiosk( sender, kioskEvent, objKiosk );
}
The second parameter in the EventHandler would be an enumerator
indicating the type of event. The third parameter would pass data.
I hope this explains what I am trying to do.
I am grateful for any ideas you might have!
Thanks,
Jan Roelof