Is there a way I can generate code from each value of an enum that I am wrapping ?

 

Say I have this class in C++:

 

class MyClass

{

public:

                enum Message {
                                kMessageA,

                                kMessageB,

                                kMessageC,

                                ...

                                kMessageZ,

                                kMessageLast

                };

};

 

I would like this to be generated in the C# class

 

public class MyClass

{

public event EventHandler kMessageA;

public event EventHandler kMessageB;

public event EventHandler kMessageC;

...

public event EventHandler kMessageZ;

};

 

With SWIG is it possible to enumerate all values of my enum and add a member in my class for each value.

 

So that I end up with as many event handlers as I had messages in my enum.

 

Users will do this:

                MyClass myClass = new MyClass();

                myClass.kMessageA +=  myCallback;

 

I could do the following instead:

 

public class MyClass

{

                public event EventHandler[] kMessages = new EventHandler [Message.kMessageLast];

}

 

but I don’t find it as elegant since the users would then need to do the following:

 

                MyClass myClass = new MyClass();

                myClass.kMessages[MyClass.Message.kMessageA] += myCallback;

 

Thanks

 

ÉC