derived work item

Topics: CAB & Smart Client Software Factory
Mar 21, 2006 at 7:26 AM
originally posted by: spencer_jones

Is it possible to have a superclass workitem that contains event subscriptions?

I have the following code that I want in every workitem. If I define it in my WorkItem directly it seems to work fine. However if I move this class in to a new base class that derives from WorkItem say CommonWorkItem and then derive from this new class the event is always null.

Am I being stupid?

EventPublication(CommonTypes.PluginStatusMessage, PublicationScope.Global)
public event EventHandler<DataEventArgs<PluginInfo>> NotifyPluginStatusChanged;

/// <summary>
/// Called whenever the status of the workitem changes to notify the client
/// workbench.
/// </summary>
/// <param name="info"></param>
public void ChangeStatus(PluginInfo info)
{
if (NotifyPluginStatusChanged != null)
{
NotifyPluginStatusChanged(this, new DataEventArgs<PluginInfo>(info));
}
}
Mar 22, 2006 at 5:07 AM
originally posted by: DLorenz

It works for me and we have tons of Event Subscriptions/Publications in the "base" class workitem that we use, which inherits directly from WorkItem. I think the problem is with the parameters of your event. I use VB.NET, but in order to use it corretly, I have to declare it like this:

Public Event NotifyPluginStatusChanged As EventHandler(Of DataEventArgs(Of PluginInfo))

I'm not sure what the C# equivalent is, maybe:

public event EventHandler<DataEventArgs<PluginInfo>> NotifyPluginStatusChanged;
Mar 22, 2006 at 5:44 AM
originally posted by: spencer_jones

On the other hand it could be that I really am stupid. The code snippet in my question was taken from the "working" class. My base class had tagged the event as "private", which seems to break it :-) That's as bad as forgetting to put a public in front of my ModuleInit derived class and wondering why the ModuleLoader keeps ignoring my plugin!

Thanks for the response,
Spencer.
Mar 22, 2006 at 7:38 AM
originally posted by: DLorenz

Heh, I've done that a few times... I setup the event subscription as private and wonder why it doesn't get the event. :)