Hello everyone I have an interface defined like so:
public interface IRipper
{
IRipperHost Host { get; set; }
void Rip(FileStream stream);
event RipperEventHandler OnStart;
event RipperEventHandler OnComplete;
event RipperEventHandler OnProgressChanged;
}
public delegate void RipperEventHandler(object sender, RipperEventArgs e);
and a base class that implements that interface
public class RipperBase : IRipper
{
public void Rip(FileStream stream)
{
throw new System.NotImplementedException();
}
public event RipperEventHandler PostRipEvent;
event RipperEventHandler IRipper.OnComplete
{
add
{
if (PostRipEvent != null)
{
lock (PostRipEvent)
{
PostRipEvent += value;
}
}
else
{
PostRipEvent = value;
}
}
remove
{
if (PostRipEvent != null)
{
lock (PostRipEvent)
{
PostRipEvent -= value;
}
}
}
}
... and so on
}
My question is how would you inherit from RipperBase and override the BaseClass Rip method. in reality that function should be abstract - but i don't know how to do that with interfaces.
Also how can i call the base classes event handler from the class derived from RipperBase? I tried this
RipperEventHandler handler = PreRipEvent;
if (handler != null)
{
handler(this, new RipperEventArgs { Message = "Started Ripping file to CSV!" });
}
handler = RipProgEvent;
this but I'm getting the "event can only appear on the left hand side of += or -=." error
any help would be greatly appreciated! I'm trying to make this as scalable as possible.