public FinalRegistrar( IActivityMonitor monitor, StObjObjectEngineMap engineMap, IAutoServiceKindComputeFacade kindComputeFacade) { _monitor = monitor; _engineMap = engineMap; _infos = new Dictionary <AutoServiceClassInfo, BuildClassInfo>(); _kindComputeFacade = kindComputeFacade; }
public IStObjServiceFinalManualMapping?GetFinalMapping( IActivityMonitor m, StObjObjectEngineMap engineMap, IAutoServiceKindComputeFacade kindComputeFacade, ref bool success) { if (!_finalMappingDone) { _finalMappingDone = true; Class.ComputeFinalTypeKind(m, kindComputeFacade, new Stack <AutoServiceClassInfo>(), ref success); if (Assignments.Any()) { _finalMapping = engineMap.CreateServiceFinalManualMapping(this); } } return(_finalMapping); }
public static IReadOnlyCollection <InterfaceFamily> Build( IActivityMonitor m, StObjObjectEngineMap _, IEnumerable <AutoServiceClassInfo> classes) { var families = new Dictionary <AutoServiceInterfaceInfo, InterfaceFamily>(); bool familiesHasBeenMerged = false; foreach (var c in classes) { Debug.Assert(c.IsIncluded && c.Interfaces != null && (c.Interfaces.Count == 0 || c.Interfaces.Any(i => i.SpecializationDepth == 0))); foreach (var baseInterface in c.Interfaces.Where(i => !i.IsSpecialized)) { InterfaceFamily?currentF = null; var rootInterfaces = baseInterface.SpecializationDepth == 0 ? new[] { baseInterface } : baseInterface.Interfaces.Where(i => i.SpecializationDepth == 0); foreach (var root in rootInterfaces) { if (families.TryGetValue(root, out var f)) { if (currentF == null) { currentF = f; } else if (currentF != f) { currentF.MergeWith(f); families[root] = currentF; m.Info($"Family interfaces merged because of '{baseInterface.Type}'."); familiesHasBeenMerged = true; } } else { if (currentF == null) { currentF = new InterfaceFamily(); } families.Add(root, currentF); } currentF._interfaces.AddRange(baseInterface.Interfaces); currentF._interfaces.Add(baseInterface); } if (currentF != null) { if (!currentF._classes.ContainsKey(c)) { currentF._classes.Add(c, new SCRClass(currentF, c)); } } } } IReadOnlyCollection <InterfaceFamily> result = families.Values; if (familiesHasBeenMerged) { result = result.Distinct().ToList(); } return(result); }