From: SteveR on 21 May 2010 08:57 Based on Tom Shelton's recommendation to use an interface class to manage multiple .dll's, I started to write one but got stuck when it came to the event. I have the following event in my .dll's: public event EventHandler<PlayStateArgs> PlayStateEvent; public class PlayStateArgs : EventArgs { private readonly string _strData; public PlayStateArgs(string strData) { _strData = strData; } public string strData { get { return _strData; }} } I can create the event in the interface like: public interface IVideo { event EventHandler PlayStateEvent; } But I don't know what to do about the <PlayStateArgs> part... How do you write this?
From: Willem van Rumpt on 21 May 2010 09:03 On 21-5-2010 14:57, SteveR wrote: > Based on Tom Shelton's recommendation to use an interface class to manage > multiple .dll's, I started to write one but got stuck when it came to the > event. I have the following event in my .dll's: > > public event EventHandler<PlayStateArgs> PlayStateEvent; > > > public class PlayStateArgs : EventArgs > > { > > private readonly string _strData; > > public PlayStateArgs(string strData) > > { > > _strData = strData; > > } > > public string strData { get { return _strData; }} > > } > > > I can create the event in the interface like: > > public interface IVideo > { > event EventHandler PlayStateEvent; > } > > But I don't know what to do about the<PlayStateArgs> part... How do you > write this? Exactly as you would expect: public interface IVideo { event EventHandler<PlayStateArgs> PlayStateEvent; } -- Willem van Rumpt
From: Steve Ricketts on 21 May 2010 09:46 I tried that first: event EventHandler<PlayStateArgs> PlayStateEvent; but it says PlayStateArgs could not be found. I tried adding "class PlayStateArgs : EventArgs" but couldn't get the syntax right. What would be the syntax for specifying the PlayStateArgs? Thanks! "Willem van Rumpt" <wdotvandotrumpt(a)skoutsoftdotcom> wrote in message news:#VOD3XO#KHA.1892(a)TK2MSFTNGP05.phx.gbl... > On 21-5-2010 14:57, SteveR wrote: >> Based on Tom Shelton's recommendation to use an interface class to manage >> multiple .dll's, I started to write one but got stuck when it came to the >> event. I have the following event in my .dll's: >> >> public event EventHandler<PlayStateArgs> PlayStateEvent; >> >> >> public class PlayStateArgs : EventArgs >> >> { >> >> private readonly string _strData; >> >> public PlayStateArgs(string strData) >> >> { >> >> _strData = strData; >> >> } >> >> public string strData { get { return _strData; }} >> >> } >> >> >> I can create the event in the interface like: >> >> public interface IVideo >> { >> event EventHandler PlayStateEvent; >> } >> >> But I don't know what to do about the<PlayStateArgs> part... How do you >> write this? > > Exactly as you would expect: > > public interface IVideo > { > event EventHandler<PlayStateArgs> PlayStateEvent; > } > > -- > Willem van Rumpt
From: Peter Duniho on 21 May 2010 11:39 Steve Ricketts wrote: > I tried that first: event EventHandler<PlayStateArgs> PlayStateEvent; > but it says PlayStateArgs could not be found. I tried adding "class > PlayStateArgs : EventArgs" but couldn't get the syntax right. What > would be the syntax for specifying the PlayStateArgs? The PlayStateArgs type needs to be visible to the assembly declaring the interface itself. Either declare it in that interface (which is probably the best approach, since presumably the EventArgs type is closely tied to the interface type in which the event must be implemented), or have that assembly reference the assembly where the PlayStateArgs is defined. Pete
From: Willem van Rumpt on 21 May 2010 11:43
On 21-5-2010 15:46, Steve Ricketts wrote: > I tried that first: event EventHandler<PlayStateArgs> PlayStateEvent; > but it says PlayStateArgs could not be found. I tried adding "class > PlayStateArgs : EventArgs" but couldn't get the syntax right. What would > be the syntax for specifying the PlayStateArgs? > > Thanks! > Assuming the PlayStateArgs class is in the same assembly, you'll have to include a "using" directive in the unit, or fully qualify the classname, so either a using <Your.Namespace> or a event EventHandler<Your.Namespace.PlayStateArgs> PlayStateEvent is needed. If it isn't in the same assembly, you need to reference the containing assembly first, then proceed as described above. -- Willem van Rumpt |