public override void TranslateTypes <TItem, TDom>(ITypeParent parent, IDeclaredTypes <TItem, TDom> ambigTypes) { foreach (IDeclaredType <TDom> ambigDeclType in ambigTypes.Values) { //Emit the root, if it exists as a child of the type, //-or- if the type is segmentable, the parent is segmentable, and the instances //align. if ((ambigDeclType.ParentTarget == parent) || ((!(options.AllowPartials)) && (parent is ISegmentableDeclarationTarget) && (ambigDeclType.ParentTarget is ISegmentableDeclarationTarget) && (((ISegmentableDeclarationTarget)(parent)).GetRootDeclaration() == ((ISegmentableDeclarationTarget)(ambigDeclType.ParentTarget)).GetRootDeclaration()))) { TranslateType(ambigDeclType); } //Don't exclude the possibility that a partial of the same type //might have been inserted into the -same- parent instance. //Not likely, but possible and legal. But only legal if partials are. if (options.AllowPartials && (ambigDeclType is ISegmentableDeclaredType)) { foreach (IDeclaredType <TDom> ambigDeclTypePartial in ((ISegmentableDeclaredType)(ambigDeclType)).Partials) { if (ambigDeclTypePartial.ParentTarget == parent) { TranslateType(ambigDeclTypePartial); } } } } }
public abstract void TranslateTypes <TItem, TDom>(ITypeParent parent, IDeclaredTypes <TItem, TDom> ambigTypes) where TItem : IDeclaredType <TDom> where TDom : CodeTypeDeclaration;
private void GatherTypes <TItem, TDom>(List <IDeclaredType> target, List <IIntermediateProject> projectPartials, IDeclaredTypes <TItem, TDom> declaredTypes) where TItem : IDeclaredType <TDom> where TDom : CodeTypeDeclaration { /* * * Doesn't go beyond the top-level types, because most .NET Compilers * flatten object hierarchies (nested types) that span across multiple modules. * That is, if Type A is in Module 1 and Type A+B is in Module 2 * A+B end up both in Module 1. * */ if (declaredTypes == null) { return; } foreach (IDeclaredType <TDom> type in declaredTypes.Values) { if (type.Module == this && (!projectPartials.Contains(type.Project))) { target.Add(type); projectPartials.Add(type.Project); if (type is ITypeParent) { GatherTypes(target, projectPartials, (ITypeParent)type); } } } }