/// <summary> /// Determine the complete list of types reachable as a consequence of a starting group of types. /// </summary> /// <remarks> /// Provide a single shared implementation that is used either at type-level checks, as well as in diagnostic checks to ensure fidelity of result. /// </remarks> /// <param name="initialTypes">The types to start searching from.</param> /// <param name="ancestorsOnlyOnFirst"></param> /// <param name="getTargets"> /// False to follow relationships in reverse to potential sources of grants. /// True to follow relationships in forward to target types that receive grants. /// </param> /// <returns></returns> public static IEnumerable <WalkStep <Tuple <Relationship, Direction, EntityType, EntityType> > > ReachableTypes(IEnumerable <EntityType> initialTypes) { var entityComparer = new EntityIdEqualityComparer <EntityType>( ); var tupleComparer = new CastingComparer <Tuple <Relationship, Direction, EntityType, EntityType>, EntityType>(t => t.Item3, entityComparer); return(Delegates.WalkGraphWithSteps( initialTypes.Select(et => new Tuple <Relationship, Direction, EntityType, EntityType>(null, Direction.Forward, et, null)), tuple => { EntityType et = tuple.Item3; var securingRelationships = GetSecuredRelationships(et, false, false); // hmm .. this should probably pass true return securingRelationships; // Item3 = the next entityType }, tupleComparer )); }
/// <summary>Try get a custom comparer for <paramref name="type"/></summary> /// <param name="type">The type.</param> /// <param name="comparer">The comparer.</param> /// <returns>True if a custom comparer is provided for <paramref name="type"/></returns> public bool TryGetComparer(Type type, out CastingComparer comparer) { comparer = null; return this.comparers?.TryGetValue(type, out comparer) == true; }