Reputation: 49482
Is there a .NET framework interface like this?
public interface IEvent
{
event EventHandler Event;
}
I can of course write my own, but I'll reuse it if it already exists. Could perhaps have a Fire/Raise method on it too.
Upvotes: 1
Views: 284
Reputation: 62950
Not yet, but there will be in .Net 4.0, IObservable<T>
and IObserver<T>
interfaces part of the Reactive Framework, see info on Paul Batum blog.
This is how the interfaces are in their current incarnation:
interface IObservable<out T>
{
IDisposable Subscribe(IObserver o);
}
interface IObserver<in T>
{
void OnCompleted();
void OnNext(T v);
void OnError(Exception e);
}
Upvotes: 2
Reputation: 9146
There's no real match to this in the .NET world. Can I suggest though, that you look into an implementation of the EventPool? This has the ability to fire events, and the events can be described as enums (or the like).
Upvotes: 0
Reputation: 185643
No, there is no such standard interface in the BCL or any other .NET class libraries, at least as far as I am aware.
Upvotes: 0
Reputation: 754763
No there is not.
Typically events in C# / CLR do not use an interface base pattern as shown in your question. This is much more akin to the Java style of eventing. The closest item would be a generic event delegate which can be re-used instead of creating new delegate types. This does exist in System.EventHandler<TEventArgs>
Upvotes: 9