I have IServiceHandlerand ISalesHandlerand both are inherited fromIhandler
IHandler.cs
public interface IHandler
{
Task AddAsync(IEnumerable<IDictionary<string, object>> toAdd, int dataFileId);
Task AddAuditAsync(IEnumerable<IDictionary<string, object>> toAdd, int dataFileId);
}
IServiceHandler.cs
public interface IServiceHandler : IHandler
{
Task<IEnumerable<ACService>> GetAsync();
Task<IEnumerable<ACServiceAudit>> GetAuditAsync();
}
ISalesHandler.cs
public interface ISalesHandler : IHandler
{
Task<IEnumerable<ACSale>> GetAsync();
Task<IEnumerable<ACSaleAudit>> GetAuditAsync();
}
Then I have a method that returns Sales or Service, but the problem is that I return it as Ihandler
private IHandler CreateHandler(FileType type)
{
switch (type)
{
case FileType.Sales:
return _container.GetExportedValue<ISalesHandler>("Sales");
case FileType.Service:
return _container.GetExportedValue<IServiceHandler>("Service");
case FileType.None:
return null;
}
return null;
}
which makes me access methods in Ihandler, not in IServiceHandleror ISalesHandler.
How can I structure interfaces to access all methods? I would rather save the method CreateHandler.
source
share