public static async Task <Case> HasMajorRecordsInTree(ObjectGeneration obj, bool includeBaseClass, GenericSpecification specifications = null) { if (await HasMajorRecords(obj, includeBaseClass: includeBaseClass, includeSelf: false, specifications: specifications) == Case.Yes) { return(Case.Yes); } // If no, check subclasses foreach (var inheritingObject in await obj.InheritingObjects()) { if (await HasMajorRecordsInTree(inheritingObject, includeBaseClass: false, specifications: specifications) == Case.Yes) { return(Case.Yes); } } return(Case.No); }
public static async Task <Case> HasLinks(ObjectGeneration obj, bool includeBaseClass, GenericSpecification specifications = null) { if (obj.Name == "MajorRecord") { return(Case.Yes); } if (obj.IterateFields(includeBaseClass: includeBaseClass).Any((f) => f is FormLinkType)) { return(Case.Yes); } Case bestCase = Case.No; foreach (var field in obj.IterateFields(includeBaseClass: includeBaseClass)) { if (field is LoquiType loqui) { var subCase = await HasLinks(loqui, includeBaseClass, specifications); if (subCase > bestCase) { bestCase = subCase; } } else if (field is ContainerType cont) { if (cont.SubTypeGeneration is LoquiType contLoqui) { var subCase = await HasLinks(contLoqui, includeBaseClass, specifications); if (subCase > bestCase) { bestCase = subCase; } } else if (cont.SubTypeGeneration is FormLinkType) { return(Case.Yes); } } else if (field is DictType dict) { if (dict.ValueTypeGen is LoquiType valLoqui) { var subCase = await HasLinks(valLoqui, includeBaseClass, specifications); if (subCase > bestCase) { bestCase = subCase; } } if (dict.KeyTypeGen is LoquiType keyLoqui) { var subCase = await HasLinks(keyLoqui, includeBaseClass, specifications); if (subCase > bestCase) { bestCase = subCase; } } if (dict.ValueTypeGen is FormLinkType) { return(Case.Yes); } } } // If no, check subclasses if (bestCase == Case.No) { foreach (var inheritingObject in await obj.InheritingObjects()) { var subCase = await HasLinks(inheritingObject, includeBaseClass : false, specifications : specifications); if (subCase != Case.No) { return(Case.Maybe); } } } return(bestCase); }