本文整理汇总了C#中Dependency.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Dependency.Add方法的具体用法?C# Dependency.Add怎么用?C# Dependency.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dependency
的用法示例。
在下文中一共展示了Dependency.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
public void Check(ConstructorInfo info, Dependency parent)
{
if (info.IsPrivate && !info.ReflectedType.IsAbstract)
{
parent.Add(new ProblemDependency(string.Format("This is a private constructor")));
}
}
开发者ID:royosherove,项目名称:dotnet-depender,代码行数:7,代码来源:FindPrivateConstructorsOnNonAbstractClassesRule.cs
示例2: Check
public void Check(FieldInfo info, Dependency parent)
{
// Dependency parent = new Dependency(info.);
bool isInterface = info.FieldType.IsInterface;
bool isAbstract = info.FieldType.IsAbstract;
bool isNotSealed = !info.FieldType.IsSealed;
string message = "";
if (isInterface)
{
message = string.Format("Field {0} is interface {1}", info.Name, info.FieldType.Name);
}
else if (isAbstract)
{
message = string.Format("Field {0} is an abstract class {1} and can be inherited from", info.Name,info.FieldType.Name);
}
else if (isNotSealed)
{
message =
string.Format("Field {0} is non sealed {1} and can be inherited from", info.Name,
info.FieldType.Name);
}
parent.Add(new Dependency(message));
// if (parent.AlreadyContains(info.FieldType))
// {
// parent.Add(new Dependency(message));
// }
// else
// {
// parent.Add(new Dependency(info.FieldType, message));
// }
}
示例3: Check
public void Check(MethodInfo info, Dependency parent)
{
if (!info.IsFinal && (info.IsVirtual || info.IsAbstract))
{
parent.Add(new Dependency(string.Format(" {0}() can be overriden", info.Name)));
}
}
示例4: DoChecks
protected override void DoChecks(MethodBase mehodBeingChecked, MethodBodyInfo methodBody, Dependency parent)
{
foreach (ILInstruction instruction in methodBody.Instructions)
{
if (instruction is InlineMethodInstruction)
{
InlineMethodInstruction line = instruction as InlineMethodInstruction;
if (line.Method.IsVirtual)
{
parent.Add(new VirtualMethodCallDependency(line.Method.ReflectedType.Name, line.Method.Name));
}
}
}
}
示例5: DoChecks
protected override void DoChecks(MethodBase mehodBeingChecked, MethodBodyInfo methodBody, Dependency parent)
{
foreach (ILInstruction instruction in methodBody.Instructions)
{
if (instruction is InlineMethodInstruction)
{
InlineMethodInstruction line = instruction as InlineMethodInstruction;
if (line.Method.IsStatic)
{
string message =
string.Format("Static method call {0} on {1}", line.Method.Name,
line.Method.ReflectedType.Name);
parent.Add(new ProblemDependency(message));
}
}
}
}