Hello all -
So I'm setting up some boilerplate code to be used internally for a common type of application. The applications will take a file and upload the data to a database. This factors out into two interfaces:
Simple enough. The IDataUploader is responsible for getting the data into the database, and the IStatusReporter is responsible for reporting his progress back to the caller.
Here's my question:
In the form that will declare an instance of a concrete implementation, what would be the desired way to do this? My implementing class implements both interfaces, and I want the form to only know about the interfaces, not the class.
So when I declare the object:
protected IDataUploader m_DataUploader;
Well, I guess you see the problem. I can only set his type to one interface.
For now, I have declared essentially an empty interface that only serves to pull the two together:
But that seems a little ugly to me, and really negates my original intention of keeping the two separate concerns... well, separate.
Is there a more elegant solution to this situation?
Thanks for your input.
-paul
The answer to getting answered -- faq855-2992
So I'm setting up some boilerplate code to be used internally for a common type of application. The applications will take a file and upload the data to a database. This factors out into two interfaces:
Code:
public interface IDataUploader
{
void Upload(string p_Path, Database p_Database);
}
public interface IStatusReporter
{
event ProgressChangedEventHandler ProgressChanged;
event StatusChangedEventHandler StatusChanged;
event ExceptionRaisedEventHandler ExceptionRaised;
}
Here's my question:
In the form that will declare an instance of a concrete implementation, what would be the desired way to do this? My implementing class implements both interfaces, and I want the form to only know about the interfaces, not the class.
So when I declare the object:
protected IDataUploader m_DataUploader;
Well, I guess you see the problem. I can only set his type to one interface.
For now, I have declared essentially an empty interface that only serves to pull the two together:
Code:
public interface IUploaderAndStatusReporter : IDataUploader , IStatusReporter{}
Is there a more elegant solution to this situation?
Thanks for your input.
-paul
The answer to getting answered -- faq855-2992