예제 #1
0
 public CKTypeCollector(IActivityMonitor monitor,
                        IServiceProvider serviceProvider,
                        IDynamicAssembly tempAssembly,
                        Func <IActivityMonitor, Type, bool>?typeFilter = null,
                        IEnumerable <string>?names = null)
 {
     Throw.CheckNotNullArgument(monitor);
     Throw.CheckNotNullArgument(serviceProvider);
     Throw.CheckNotNullArgument(tempAssembly);
     _monitor              = monitor;
     _typeFilter           = typeFilter ?? ((m, type) => type.FullName != null);
     _tempAssembly         = tempAssembly;
     _serviceProvider      = serviceProvider;
     _assemblies           = new HashSet <Assembly>();
     _objectCollector      = new Dictionary <Type, RealObjectClassInfo?>();
     _regularTypeCollector = new Dictionary <Type, TypeAttributesCache?>();
     _roots             = new List <RealObjectClassInfo>();
     _serviceCollector  = new Dictionary <Type, AutoServiceClassInfo>();
     _serviceRoots      = new List <AutoServiceClassInfo>();
     _serviceInterfaces = new Dictionary <Type, AutoServiceInterfaceInfo?>();
     _multipleMappings  = new Dictionary <Type, MultipleImpl>();
     KindDetector       = new CKTypeKindDetector(typeFilter);
     _pocoRegistrar     = new PocoRegistrar((m, t) => (KindDetector.GetValidKind(m, t) & CKTypeKind.IsPoco) != 0, typeFilter: _typeFilter);
     _names             = names == null || !names.Any() ? new[] { String.Empty } : names.ToArray();
 }
예제 #2
0
        /// <summary>
        /// Initializes a new <see cref="StObjObjectEngineMap"/>.
        /// </summary>
        /// <param name="names">The final map names.</param>
        /// <param name="allSpecializations">
        /// Pre-dimensioned array that will be filled with actual
        /// mutable items by <see cref="StObjCollector.GetResult()"/>.
        /// </param>
        /// <param name="typeKindDetector">The type kind detector.</param>
        /// <param name="assemblies">Reference to the set of assemblies used to implement the IStObjMap.Features property.</param>
        internal StObjObjectEngineMap(IReadOnlyList <string> names,
                                      IReadOnlyList <MutableItem> allSpecializations,
                                      CKTypeKindDetector typeKindDetector,
                                      IReadOnlyCollection <Assembly> assemblies)
        {
            Debug.Assert(names != null);
            Names = names;
            _map  = new Dictionary <object, MutableItem>();
            _finaImplementations = allSpecializations;
            _assemblies          = assemblies;

            _serviceSimpleMap  = new Dictionary <Type, IStObjServiceFinalSimpleMapping>();
            _serviceSimpleList = new List <IStObjServiceFinalSimpleMapping>();
            _exposedServiceMap = _serviceSimpleMap.AsIReadOnlyDictionary <Type, IStObjServiceFinalSimpleMapping, IStObjServiceClassDescriptor>();

            _serviceManualMap        = new Dictionary <Type, IStObjServiceFinalManualMapping>();
            _serviceManualList       = new List <IStObjServiceFinalManualMapping>();
            _exposedManualServiceMap = _serviceManualMap.AsIReadOnlyDictionary <Type, IStObjServiceFinalManualMapping, IStObjServiceClassFactory>();

            _serviceToObjectMap        = new Dictionary <Type, MutableItem>();
            _serviceRealObjects        = new List <MutableItem>();
            _serviceToObjectMapExposed = _serviceToObjectMap.AsIReadOnlyDictionary <Type, MutableItem, IStObjFinalImplementation>();
        }