public void GetBaseConceptInfoTypes() { var tests = new[] { typeof(C1), typeof(C2), typeof(C3), typeof(D1), typeof(D2), typeof(IConceptInfo), typeof(object), }; var results = tests.Select(type => ( In: type, Out: DslSyntaxFromPlugins.GetBaseConceptInfoTypes(type) )).ToList(); var report = string.Join("\r\n", results.Select(r => $"{r.In.Name}: {TestUtility.DumpSorted(r.Out, t => t.Name)}")); Assert.AreEqual( @"C1: C2: C1 C3: C1, C2 D1: D2: IConceptInfo: Object: ", report); }
public static IEnumerable <Type> GetAllRelatedConceptInfoTypes(params Type[] conceptInfoTypes) { var types = new HashSet <Type>(conceptInfoTypes); var addReferencedTypes = new HashSet <Type>(conceptInfoTypes); while (addReferencedTypes.Any()) { var newTypes = new HashSet <Type>(); foreach (Type type in addReferencedTypes) { foreach (var member in ConceptMembers.Get(type)) { if (member.IsConceptInfo && !member.IsConceptInfoInterface) { if (!types.Contains(member.ValueType)) { types.Add(member.ValueType); newTypes.Add(member.ValueType); } } } } addReferencedTypes = newTypes; } foreach (var type in types.ToList()) // Creating a copy to allow modification within the loop. { foreach (var baseType in DslSyntaxFromPlugins.GetBaseConceptInfoTypes(type)) { types.Add(baseType); } } return(types.ToArray()); }