public override ProblemCollection Check(TypeNode type) { if (mvcController != null && baseController != null) { if (type.IsAssignableTo(mvcController) && !type.IsAssignableTo(baseController)) { Problems.Add(new Problem(this.GetResolution(type.FullName))); } } return(this.Problems); }
/// <summary> /// This is used to see if a type and parameter are valid template arguments /// </summary> /// <param name="type">The type to check</param> /// <param name="parameter">The parameter to check</param> /// <returns>True if it is valid, false if not</returns> private static bool IsValidTemplateArgument(TypeNode type, TypeNode parameter) { if (type == null) { throw new ArgumentNullException("type"); } // Check that the parameter really is a type parameter ITypeParameter itp = parameter as ITypeParameter; if (itp == null) { throw new ArgumentException("The 'parameter' argument is null or not an 'ITypeParameter'."); } // Test constraints bool reference = ((itp.TypeParameterFlags & TypeParameterFlags.ReferenceTypeConstraint) > 0); if (reference && type.IsValueType) { return(false); } bool value = ((itp.TypeParameterFlags & TypeParameterFlags.ValueTypeConstraint) > 0); if (value && !type.IsValueType) { return(false); } InterfaceList contracts = parameter.Interfaces; if (contracts != null) { foreach (Interface contract in contracts) { if (!type.IsAssignableTo(contract)) { return(false); } } } TypeNode parent = parameter.BaseType; if (parent != null && !type.IsAssignableTo(parent)) { return(false); } // Okay, passed all tests return(true); }
public override Expression VisitMethodCall(MethodCall mc) { Expression result = base.VisitMethodCall(mc); mc = result as MethodCall; // check for Aggregate types if (mc != null && mc.Operands != null && mc.Operands.Count == 1) { Literal lit = mc.Callee as Literal; if (lit != null && lit.Type == SystemTypes.Type) { TypeNode type = (TypeNode)lit.Value; if (type != null && type.IsAssignableTo(SystemTypes.IAggregateGroup)) { QueryAggregate qa = new QueryAggregate(); qa.Name = type.Name; qa.AggregateType = type; qa.Expression = mc.Operands[0]; qa.SourceContext = mc.SourceContext; if (this.currentGroup != null) { this.currentGroup.AggregateList.Add(qa); qa.Group = this.currentGroup; } return(qa); } } } return(result); }
private static bool IsSubclassOf(this TypeNode thisType, TypeNode thatType) { if (thatType == null) { return(false); } return(thisType.IsAssignableTo(thatType)); }
/// <inheritdoc /> public override ProblemCollection Check(TypeNode type) { if (type.IsAssignableTo(FrameworkTypes.Exception) && type.IsAbstract == false && RuleUtilities.IsSerializable(type) == false) { Problems.Add(new Problem(GetResolution(type.Name.Name))); } return(Problems); }
public override ProblemCollection Check(TypeNode type) { if (mvcController != null && type.IsAssignableTo(mvcController) && type.Attributes?.FirstOrDefault(a => a.Type == authorizeAttribute) == null) { Problems.Add(new Problem(this.GetResolution(type.FullName))); } return(this.Problems); }
internal static bool IsPresenterImplementation(TypeNode type) { if (type.NodeType != NodeType.Class) return false; // If it's an abstract base class, let them do what they want if (type.IsAbstract) return false; var iPresenter = GetIPresenterTypeNode(type); // If we can't even find IPresenter, bail out if (iPresenter == null) return false; return type.IsAssignableTo(iPresenter); }
private static bool IsInsideSubclass(this Member member, Member thatValue) { var targetType = thatValue as TypeNode; if (targetType == null) { return(false); } for (TypeNode declaringType = member.DeclaringType; declaringType != null; declaringType = declaringType.DeclaringType) { if (declaringType.IsAssignableTo(targetType)) { return(true); } } return(false); }
internal static bool IsPresenterImplementation(TypeNode type) { if (type.NodeType != NodeType.Class) { return(false); } // If it's an abstract base class, let them do what they want if (type.IsAbstract) { return(false); } var iPresenter = GetIPresenterTypeNode(type); // If we can't even find IPresenter, bail out if (iPresenter == null) { return(false); } return(type.IsAssignableTo(iPresenter)); }
public static TypeNode LeastCommonAncestor(TypeNode t1, TypeNode t2) { if (t1.IsAssignableTo(t2)) { return(t2); } // walk up t1 until assignable to t2 TypeNode frame = t1; while (frame != null) { if (t2.IsAssignableTo(frame)) { return(frame); } frame = frame.BaseType; } // if we get here, we haven't found a common basetype. Return object return(Cci.SystemTypes.Object); }
public bool DerivesFrom(TypeNode sub, TypeNode type) { return(sub.IsAssignableTo(type)); }