我是NDpend的新客户,所以请原谅我的问题很愚蠢……我希望有一个规则来告诉我,当我的构造器有一个特定的代码行。考虑一下这个例子
public StatusViewModel
{
this.userService = ServiceLocator.Default.ResolveType<IUserService>();
}有可能吗?考虑到我要在构造函数中定义它,并且需要引用ServiceLocator.Default.ResolveType
谢谢
发布于 2017-08-06 17:07:11
如果您想强制构造函数正在访问
ServiceLocator.Default.ResolveType<IUserService>()该规则应如下所示
warnif count > 0
from m in Application.Methods
where m.IsConstructor
&& !m.IsUsing("Microsoft.Practices.ServiceLocation.ServiceLocator.get_Default()")
&& !m.IsUsing("Microsoft.Practices.ServiceLocation.ServiceLocator.ResolveType<T>()")
select mhttps://stackoverflow.com/questions/45502474
复制相似问题