My old version of the interface which is exposed to the users is this:
public interface IReporter
{
void Write(int site, DateTime start, DateTime end);
}
Now I want to replace the parameters in the function as below:
public interface IReporter
{
void Write(int site, SiteLocalDateTime start, SiteLocalDateTime end);
}
I want the existing customer to use the old method and the new customer to use the new method.
Any idea on how to achieve this by exposing single interface?
Options:
Keeping two interface with IReporter and IReporterNew : IReporter
Now all my new implementations require both the methods to be used.
Exposing two interface is not possible.
You can just combine the interfaces into one if the implementation of the method is on your end. The user can decide then which to use. (Preferably you should mark the old method obsolete, thanks 3dd)
public interface IReporter
{
[Obsolete]
void Write(int site, DateTime start, DateTime end);
void Write(int site, SiteLocalDateTime start, SiteLocalDateTime end);
}
If that is not what you are after, you should in fact version your software. One version for new customers, one 'legacy' build for existing customers. Eventually you can migrate old customers to the new version.
You can even create a conversion between the two types if the actual implementing type is known, but I am not sure if that is useful in this case.
Also, did you mean to use DateTimeOffset instead of SiteLocalDateTime?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With