public GenBinPath(StObjEngineRunContext global,
                   StObjCollectorResult result,
                   RunningBinPathGroup group)
 {
     Debug.Assert(!result.HasFatalError);
     _global            = global;
     Result             = result;
     ConfigurationGroup = group;
     Memory             = new Dictionary <object, object?>();
     ServiceContainer   = new SimpleServiceContainer(_global.ServiceContainer);
     ServiceContainer.Add(result.DynamicAssembly.GetPocoSupportResult());
 }
Example #2
0
        StObjCollectorResult?SafeBuildStObj(RunningBinPathGroup group)
        {
            Debug.Assert(_startContext != null, "Work started.");
            bool hasError = false;

            using (_monitor.OnError(() => hasError = true))
            {
                StObjCollectorResult result;
                var configurator = _startContext.Configurator.FirstLayer;
                // When head.IsUnifiedPure the type filter keeps only the IPoco and IRealObject.
                var            typeFilter = new TypeFilterFromConfiguration(group, configurator);
                StObjCollector stObjC     = new StObjCollector(_monitor,
                                                               _startContext.ServiceContainer,
                                                               _config.Configuration.TraceDependencySorterInput,
                                                               _config.Configuration.TraceDependencySorterOutput,
                                                               typeFilter,
                                                               configurator,
                                                               configurator,
                                                               group.SimilarConfigurations.Select(b => b.Name !));
                stObjC.RevertOrderingNames = _config.Configuration.RevertOrderingNames;
                using (_monitor.OpenInfo(group.IsUnifiedPure ? "Registering only IPoco and IRealObjects (Purely Unified BinPath).": "Registering types."))
                {
                    // First handles the explicit kind of Types.
                    // These are services: we don't care.
                    if (!group.IsUnifiedPure)
                    {
                        foreach (var c in group.Configuration.Types)
                        {
                            // When c.Kind is None, !Optional is challenged.
                            // The Type is always resolved.
                            stObjC.SetAutoServiceKind(c.Name, c.Kind, c.Optional);
                        }
                    }
                    // Then registers the types from the assemblies.
                    stObjC.RegisterAssemblyTypes(group.Configuration.Assemblies);
                    // Explicitly registers the non optional Types.
                    if (!group.IsUnifiedPure)
                    {
                        stObjC.RegisterTypes(group.Configuration.Types.Where(c => c.Optional == false).Select(c => c.Name).ToList());
                    }
                    // Finally, registers the code based explicitly registered types.
                    foreach (var t in _startContext.ExplicitRegisteredTypes)
                    {
                        stObjC.RegisterType(t);
                    }

                    Debug.Assert(stObjC.RegisteringFatalOrErrorCount == 0 || hasError, "stObjC.RegisteringFatalOrErrorCount > 0 ==> An error has been logged.");
                }
                if (stObjC.RegisteringFatalOrErrorCount == 0)
                {
                    using (_monitor.OpenInfo("Resolving Real Objects & AutoService dependency graph."))
                    {
                        result = stObjC.GetResult();
                        Debug.Assert(!result.HasFatalError || hasError, "result.HasFatalError ==> An error has been logged.");
                    }
                    if (!result.HasFatalError)
                    {
                        return(result);
                    }
                }
            }
            return(null);
        }
Example #3
0
 public StObjCollectorResult?GetResult(RunningBinPathGroup g) => _result;
Example #4
0
 public TypeFilterFromConfiguration(RunningBinPathGroup g, StObjConfigurationLayer?firstLayer)
 {
     _excludedTypes = g.Configuration.ExcludedTypes;
     _firstLayer    = firstLayer;
     _isUnifiedPure = g.IsUnifiedPure;
 }
 internal void AddResult(RunningBinPathGroup g, StObjCollectorResult secondaryResult)
 {
     _binPaths.Add(new GenBinPath(this, secondaryResult, g));
 }