本文整理汇总了C#中TypeNode.IsDerivedFrom方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.IsDerivedFrom方法的具体用法?C# TypeNode.IsDerivedFrom怎么用?C# TypeNode.IsDerivedFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeNode
的用法示例。
在下文中一共展示了TypeNode.IsDerivedFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
public override ProblemCollection Check(TypeNode type)
{
if (type.Attributes.Any(a => a.Type.FullName == "CDS.ProxyFactory.SingletonAttribute") && type.IsDerivedFrom("System.IDisposable"))
{
Problems.Add(new Problem(this.GetResolution()));
}
return Problems;
}
示例2: Check
public override ProblemCollection Check(TypeNode cls)
{
lock (_currentTypeLock)
{
if (!cls.IsDerivedFrom("CDS.Core.Utils.Inspection.SafeSqlBuilder"))
return Problems;
_currentType = cls;
foreach (var m in cls.Members)
{
var meth = m as Method;
if (meth != null && !m.IsPrivate)
VisitParameters(meth.Parameters);
VisitMethodCallStatements(m);
}
}
return Problems;
}
示例3: IsTypeSafe
/// <summary>
/// Numeric, bool, DateTime, etc. types are safe from SQL/XSS injection. User-defined types composed entirely of safe types are also safe.
/// </summary>
protected bool IsTypeSafe(TypeNode t, HashSet<string> checkedTypes = null)
{
if (t == null)
return true;
if (checkedTypes == null)
checkedTypes = new HashSet<string>();
else if (checkedTypes.Contains(t.FullName)) //don't recurse infinitely into self-referencing types
return true;
checkedTypes.Add(t.FullName);
if (IsStringIsh(t) || (t.TemplateArguments != null && t.TemplateArguments.Any(a => IsStringIsh(a))))
return false;
if (t.IsPrimitiveNumeric || t is EnumNode)
return true;
if (_maybeSafeGenericTypes.Any(a => t.IsDerivedFrom(a)) && t.TemplateArguments != null && t.TemplateArguments.All(a => IsTypeSafe(a, checkedTypes)))
return true;
if (_safeTypes.Contains(t.FullName))
return true;
return t.Members.Where(w => w.Name.Name != "ToString").All(a => IsTypeSafe(a, checkedTypes));
}