I have an implementation of Interfaces that I must solve: Here's an example:
interface ISettingsBase
{
string Name { get; set;}
DateTime TimeStamp { get; set; }
}
public class SettingsBase : ISettingsBase
{
public string Name { get; set; }
public DateTime TimeStamp { get; set; }
}
interface IWorkerBase
{
ISettingsBase Settings { get; set; }
}
public class WorkerBase: ISettingsBase
{
public ISettingsBase Settings { get; set; }
}
interface IExtendedSettings : ISettingsBase
{
string FilePath { get; set; }
}
interface IWorkerExtended : IWorkerBase
{
// This configuration property should respect those of
// the IWorkerBase and increase the features.
IExtendedSettings Settings { get; set; }
}
public class WorkerExtended : WorkerBase, IWorkerExtended
{
...
...
public IExtendedSettings Settings { get; set; }
}
The problem is that the compiler tells me that there is an error in WorkerExtended, and that I am not respecting the implementation of the IWorkerBase.Settings interface. The problem is that I need the new improved classes also support configurations with more properties.
WorkerExtended(and not just an instance ofIWorkerBase) and that calling itsSettingswould return an instance ofIExtendedSettings?IWorkerExtendedand not an instance ofIWorkerBase? How would it know to callmyWorker.Settings.FilePath?