|
-
April 23rd, 2009, 06:25 PM
#1
Overloading event parameters
Well, it's been a long time, but I'm back...
Obviously, I've done a lot of searching and experimenting but I'm having no luck. I have a workaround, but it's ugly, and I HATE ugly code 
Problem is, I am using events to expose functionality, but I want to be able to overload the parameters that can be used when raising said events.
i.e. I want developers using this functionality to be able to call the functionality in different ways:
RaiseEvent(string, int, int);
RasieEvent(xmldocument, int, int);
etc, etc.
I've come up with two ways around my problem:
1. Expose the events through an overloaded static methods, and then raise specific events that way (i.e. RaiseEvent1, RaiseEvent2)
2. Pass in a "EventParameters" style object.
The first is ugly. The second will not be liked by my boss - he's stressed consistently that the interface to this functionality should be as simple as possible, and even adding "new EventParameters()" will draw his ire.
To show what I want with code, basically I want to be able to go
Code:
private delegate void MyEventDelegate(String str, int num, int pos);
private delegate void MyEventDelegate(XmlDocument doc, int num, int pos);
public static event MyEventDelegate RaiseEvent;
Obviously that syntax won't work, but I hope it expresses what I mean. And yes, I understand that multiple handlers, etc would need to be coded.
Is it possible to overload events? It doesn't seem to be, but no harm in asking 
edit: VS2005 btw. .Net 2.0
Last edited by Zeb; April 23rd, 2009 at 06:29 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|