/// <summary>
        /// Initializes a new <see cref="StObjCollector"/>.
        /// </summary>
        /// <param name="monitor">Logger to use. Can not be null.</param>
        /// <param name="serviceProvider">Service provider used for attribute constructor injection. Must not be null.</param>
        /// <param name="traceDepencySorterInput">True to trace in <paramref name="monitor"/> the input of dependency graph.</param>
        /// <param name="traceDepencySorterOutput">True to trace in <paramref name="monitor"/> the sorted dependency graph.</param>
        /// <param name="typeFilter">Optional type filter.</param>
        /// <param name="configurator">Used to configure items. See <see cref="IStObjStructuralConfigurator"/>.</param>
        /// <param name="valueResolver">
        /// Used to explicitly resolve or alter StObjConstruct parameters and object ambient properties.
        /// See <see cref="IStObjValueResolver"/>.
        /// </param>
        /// <param name="names">Optional list of names for the final StObjMap. When null or empty, a single empty string is the default name.</param>
        public StObjCollector(IActivityMonitor monitor,
                              IServiceProvider serviceProvider,
                              bool traceDepencySorterInput              = false,
                              bool traceDepencySorterOutput             = false,
                              IStObjTypeFilter?typeFilter               = null,
                              IStObjStructuralConfigurator?configurator = null,
                              IStObjValueResolver?valueResolver         = null,
                              IEnumerable <string>?names = null)
        {
            Throw.CheckNotNullArgument(monitor);
            _monitor      = monitor;
            _tempAssembly = new DynamicAssembly();
            Func <IActivityMonitor, Type, bool>?tFilter = null;

            if (typeFilter != null)
            {
                tFilter = typeFilter.TypeFilter;
            }
            _cc            = new CKTypeCollector(_monitor, serviceProvider, _tempAssembly, tFilter, names);
            _configurator  = configurator;
            _valueResolver = valueResolver;
            if (traceDepencySorterInput)
            {
                DependencySorterHookInput = i => i.Trace(monitor);
            }
            if (traceDepencySorterOutput)
            {
                DependencySorterHookOutput = i => i.Trace(monitor);
            }

            AddWellKnownServices();
        }
 internal void AddMultipleMapping(Type t, CKTypeKind k, CKTypeCollector collector)
 {
     Debug.Assert(!IsSpecialized, "We are on the leaf.");
     Debug.Assert(t != Type, $"Multiple mapping {ToString()} must not be mapped to itself.");
     Debug.Assert(t.IsAssignableFrom(Type), $"Multiple mapping '{t}' must be assignable from {ToString()}!");
     Debug.Assert(_multipleMappings == null || !_multipleMappings.Contains(t), $"Multiple mapping '{t}' already registered in {ToString()}.");
     Debug.Assert(_uniqueMappings == null || !_uniqueMappings.Contains(t), $"Multiple mapping '{t}' already registered in UNIQUE mappings of {ToString()}.");
     Debug.Assert((k & CKTypeKind.IsMultipleService) != 0);
     if (_multipleMappings == null)
     {
         _multipleMappings = new List <Type>();
     }
     _multipleMappings.Add(t);
     if ((k & (CKTypeKind.IsFrontService | CKTypeKind.IsMarshallable)) != (CKTypeKind.IsFrontService | CKTypeKind.IsMarshallable))
     {
         collector.RegisterMultipleInterfaces(t, k, this);
     }
 }