下面的代码好吗?我在问自己界面中的Start()andStop()方法ICustomTimer是否可以作为位置。因为我在 Main 方法中需要它。
这是一种代码异味,或者换句话说,调用没有抽象的基本方法的最佳实践是什么?Timer类没有可用于继承的接口。
public interface ICustomTimer
{
string Value { get; set; }
//Implementation in Timer
void Start();
//Implementation in Timer
void Stop();
}
public class CustomTimer : System.Timers.Timer, ICustomTimer
{
public string Value { get; set; }
}
public Main()
{
var customTimerObj = iocContainer.Get<ICustomTimer>();
customTimerObj.Start();
}
缥缈止盈
相关分类