I have a Logger class which is implemented singleton. The class is simple and there are few methods and one static property, Instance. Like all singleton classes, I access the unique instance via Logger.Instance property.
I extracted an interface from Logger class (using Visual Studio refactor context menu). After extraction, interface contains signature for those few methods, and since the Instance property is static, it is not included in ILogger interface.
After all of this, I cannot cast a Logger.Instance into ILogger at run-time. What is wrong with my approach ?
Did you actually declare that
LoggerimplementsILogger?If so, it should be fine. Please post some code so we can try to diagnose the issue.
If not, that’s the problem, and it’s easily fixed 🙂