Beispiel #1
0
      internal ModuleImpl( ApplicationValidationResultIQ validationResult, DictionaryQuery<CompositeModel, PublicCompositeTypeGenerationResult> loadingResults, LayerImpl layer, ModuleModel model )
      {
         ArgumentValidator.ValidateNotNull( "Layer instance", layer );
         ArgumentValidator.ValidateNotNull( "Module model", model );

         this._layer = layer;
         this._moduleModel = model;
         this._serviceContainer = new ThreadsafeServiceContainer();
         this._modelInfoContainer = new ModelInfoContainerImpl(
            layer.InternalApplication.ModelTypeSupportInternal,
            model.CompositeModelsInThisContainer,
            validationResult,
            loadingResults,
            layer.Application.CollectionsFactory,
            model.LayerModel.ApplicationModel.GenericPropertyMixinType,
            model.LayerModel.ApplicationModel.GenericEventMixinType
            );
#if SILVERLIGHT
         this._compositeTypeLookupCache = new Dictionary<CompositeModelType, IDictionary<Type[], Tuple<CompositeInstanceStructureOwner, CompositeModel>>>();
#else
         this._compositeTypeLookupCache = new System.Collections.Concurrent.ConcurrentDictionary<CompositeModelType, System.Collections.Concurrent.ConcurrentDictionary<Type[], Tuple<CompositeInstanceStructureOwner, CompositeModel>>>();
#endif

         this._serviceProvider = new StructureServiceProviderImpl(
            this,
            layer.InternalApplication.ModelTypeSupportInternal,
            matcher => this.FindVisibleModels( matcher )
            );
      }
        protected CompositeModel NewCompositeModel(DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelSupports, ApplicationModel <ApplicationSPI> appModel, CompositeAssemblyInfo compositeInfo, String architectureContainerID)
        {
            var result = compositeModelSupports[compositeInfo.CompositeModelType].NewCompositeModel(appModel, compositeInfo, this.LaunchAttributeProcessingEvent, architectureContainerID);

            this.CompositeModelCreatedEvent.InvokeEventIfNotNull(evt => evt(this, new CompositeModelCreatedArgs(result)));
            return(result);
        }
        internal SingletonApplicationImpl(
            SingletonApplicationModel applicationModel,
            IEnumerable <Tuple <CompositeModelType, CompositeModelTypeModelScopeSupport> > compositeModelTypeSupport,
            ApplicationValidationResultIQ validationResult,
            DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults,
            String name,
            String mode,
            String version
            )
            : base(
                applicationModel,
                compositeModelTypeSupport,
                name,
                mode,
                version
                )
        {
            this._modelInfoContainer       = new ModelInfoContainerImpl(this.InternalModelSupport, applicationModel.CompositeModelsInThisContainer, validationResult, loadingResults, this.CollectionsFactory, applicationModel.GenericPropertyMixinType, applicationModel.GenericEventMixinType);
            this._structureServiceProvider = new StructureServiceProviderImpl(
                this,
                this.ModelTypeSupport,
                matcher => applicationModel.CompositeModelsInThisContainer
                .Where(matcher)
                .Select(model => Tuple.Create <CompositeInstanceStructureOwner, CompositeModel>(this, model))
                );

            this._serviceContainer = new ThreadsafeServiceContainer();
        }
Beispiel #4
0
        public CompositeStateImpl(CollectionsFactory collectionFactory, ListQuery <CompositeProperty> properties, ListQuery <CompositeEvent> events)
        {
            IDictionary <MethodInfo, QualifiedName>        qNames        = new Dictionary <MethodInfo, QualifiedName>();
            IDictionary <QualifiedName, CompositeProperty> propertiesDic = new Dictionary <QualifiedName, CompositeProperty>();
            IDictionary <QualifiedName, CompositeEvent>    eventsDic     = new Dictionary <QualifiedName, CompositeEvent>();

            foreach (CompositeProperty property in properties)
            {
                PropertyInfo  pInfo = property.ReflectionInfo;
                QualifiedName qName = property.QualifiedName;
                qNames.Add(pInfo.GetGetMethod(), qName);
                qNames.Add(pInfo.GetSetMethod(), qName);
                propertiesDic.Add(qName, property);
            }
            foreach (CompositeEvent evt in events)
            {
                EventInfo     eInfo = evt.ReflectionInfo;
                QualifiedName qName = evt.QualifiedName;
                qNames.Add(eInfo.GetAddMethod(), qName);
                qNames.Add(eInfo.GetRemoveMethod(), qName);
                eventsDic.Add(qName, evt);
            }

            this._qNames     = collectionFactory.NewDictionaryProxy(qNames).CQ;
            this._properties = collectionFactory.NewDictionaryProxy(propertiesDic).CQ;
            this._events     = collectionFactory.NewDictionaryProxy(eventsDic).CQ;
        }
Beispiel #5
0
        public ApplicationSkeleton(
            ApplicationModel <ApplicationSPI> applicationModel,
            IEnumerable <Tuple <CompositeModelType, CompositeModelTypeModelScopeSupport> > compositeModelTypeSupport,
            String name,
            String mode,
            String version
            )
        {
            this._model = applicationModel;
            this._collectionsFactory = applicationModel.CollectionsFactory;
            this._name    = name;
            this._mode    = mode;
            this._version = version;
            this._constraintInstancePools = new
#if SILVERLIGHT
                                            Dictionary <Type, InstancePool <Object> >();
#else
                                            System.Collections.Concurrent.ConcurrentDictionary <Type, InstancePool <Object> >();
#endif

            this._compositeModelTypeSupport = this._model.CollectionsFactory.NewDictionaryProxy <CompositeModelType, CompositeModelTypeInstanceScopeSupport>(compositeModelTypeSupport.ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2.CreateInstanceScopeSupport())).CQ;

            this._activationState = (Int32)ActivationState.PASSIVE;
            //this._disposedState = Convert.ToInt32( false );
            this._activationInProgress  = null;
            this._passivationInProgress = null;
            this._cancelTokenSource     = new CancellationTokenSource();
        }
Beispiel #6
0
        public AttributeHolderImpl(
            CollectionsFactory collectionsFactory,
            IEnumerable <MemberInfo> reflectedInfos
            )
        {
            Attribute[] attributes = reflectedInfos
                                     .SelectMany(info => info.GetCustomAttributes(true))
                                     .Distinct()
                                     .Cast <Attribute>()
                                     .ToArray();

            IDictionary <Type, ListProxy <Attribute> > dic = new Dictionary <Type, ListProxy <Attribute> >();

            foreach (Attribute attr in attributes)
            {
                ListProxy <Attribute> list;
                if (!dic.TryGetValue(attr.GetType(), out list))
                {
                    list = collectionsFactory.NewListProxy <Attribute>();
                    dic.Add(attr.GetType(), list);
                }
                list.Add(attr);
            }
            this._allAttributes = collectionsFactory.NewDictionary <Type, ListProxy <Attribute>, ListProxyQuery <Attribute>, ListQuery <Attribute> >(dic).MQ.IQ;
        }
 public PageGridData <DictionaryDto> GetDictionaryPage(DictionaryQuery query)
 {
     using (var dbScope = _dbScopeFactory.CreateReadOnly())
     {
         var db   = dbScope.DbContexts.Get <FireProjDbContext>();
         var data = db.Dictionary.Select(r => new DictionaryDto
         {
             Id          = r.Id,
             Name        = r.Name,
             Value       = r.Value,
             Description = r.Description,
             Status      = r.Status,
             ParentId    = r.ParentId,
         });
         if (!string.IsNullOrEmpty(query.Search))
         {
             data = data.Where(r => r.Name.Contains(query.Search));
         }
         var result = data.OrderBy(r => r.Id).ToList();
         var total  = data.Count();
         return(new PageGridData <DictionaryDto> {
             rows = result, total = total
         });
     }
 }
        internal LayeredApplicationImpl(
            LayeredApplicationModel model,
            IEnumerable <Tuple <CompositeModelType, CompositeModelTypeModelScopeSupport> > compositeModelTypeSupport,
            ApplicationValidationResultIQ validationResult,
            DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults,
            String name,
            String mode,
            String version
            )
            : base(
                model,
                compositeModelTypeSupport,
                name,
                mode,
                version
                )
        {
            DictionaryProxy <LayerModel, LayerImpl> allLayers = model.CollectionsFactory.NewDictionaryProxy <LayerModel, LayerImpl>();

            foreach (LayerModel layerModel in model.TopLevelLayers)
            {
                this.ProcessLayers(validationResult, loadingResults, allLayers, layerModel);
            }

            this._allLayers = allLayers.CQ;
        }
Beispiel #9
0
        protected ModuleModelMutable NewModuleModel(DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport, DictionaryProxy <Int32, CompositeModel> models, LayerModelMutable owningLayer, ModuleArchitectureImpl module)
        {
            var state     = new ModuleModelState(this.CollectionsFactory);
            var immutable = new ModuleModelImmutable(state);
            var result    = new ModuleModelMutable(state, immutable);

            state.ModuleName = module.Name;
            state.LayerModel = owningLayer;
            state.Assembler  = module.LayeredCompositeAssembler;

            foreach (var modelType in this.ModelTypeSupport.Keys)
            {
                IDictionary <CompositeModel, Visibility> visibilities = null;
                if (!state.CompositeVisibilities.TryGetValue(modelType, out visibilities))
                {
                    visibilities = new Dictionary <CompositeModel, Visibility>(ReferenceEqualityComparer <CompositeModel> .ReferenceBasedComparer);
                    state.CompositeVisibilities.Add(modelType, visibilities);
                }
                foreach (LayeredCompositeAssemblyInfo info in module.LayeredCompositeAssembler.GetInfos(modelType).Cast <LayeredCompositeAssemblyInfo>())
                {
                    var cModel = this.NewCompositeModel(compositeModelTypeSupport, owningLayer.IQ.ApplicationModel, info, owningLayer.IQ.LayerName + "-" + module.Name);
                    models.Add(cModel.CompositeModelID, cModel);
                    state.CompositeModels.Add(cModel);
                    visibilities.Add(cModel, info.Visibility);
                }
            }

            return(result);
        }
Beispiel #10
0
 internal LayerImpl(ApplicationValidationResultIQ validationResult, DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults, LayeredApplicationImpl application, LayerModel layerModel)
 {
     this._application = application;
     this._model       = layerModel;
     this._modules     = layerModel.ApplicationModel.CollectionsFactory.NewDictionaryProxy <ModuleModel, Module>(
         layerModel.ModuleModels.ToDictionary(model => model, model => (Module) new ModuleImpl(validationResult, loadingResults, this, model))
         ).CQ;
 }
Beispiel #11
0
 internal DictionaryQueryOfMutablesImpl(DictionaryQuery <TKey, TValueImmutable> immutableQuery, DictionaryQueryOfQueries <TKey, TValueQuery, TValueImmutable> cmq, DictionaryWithRolesState <TKey, TValue, TValueQuery, TValueImmutable> state)
     : base(state)
 {
     ArgumentValidator.ValidateNotNull("Immutable query", immutableQuery);
     this._state = state;
     this._cmq   = cmq;
     this._iq    = immutableQuery;
 }
        protected ApplicationArchitectureSkeleton(IEnumerable <CompositeModelTypeAssemblyScopeSupport> modelTypeSupport)
        {
            ArgumentValidator.ValidateNotNull("Composite model type supports", modelTypeSupport);

            this._collectionsFactory = CollectionsFactorySingleton.DEFAULT_COLLECTIONS_FACTORY;
            this._modelTypeSupport   = this._collectionsFactory.NewDictionaryProxy(modelTypeSupport.ToDictionary(support => support.ModelType, support => support)).CQ;
            this._metaInfoContainer  = UsesContainerMutableImpl.CreateEmpty();
            this._additionalInjectionFunctionalities = this._collectionsFactory.NewDictionaryProxy <Type, InjectionFunctionality>();
        }
        //protected virtual CompositeInstanceImpl CreateNewCopy( IEnumerable<Type> publicCompositeTypes, UsesContainerQuery uses )
        //{
        //   return new CompositeInstanceImpl( this._structureOwner, this._modelInfo.Model, publicCompositeTypes, uses );
        //}

        protected InstancePoolInfo <TInvocation> FindPool <TInvocation>(Type key, DictionaryQuery <Type, InstancePoolInfo <TInvocation> > dic)
        {
            InstancePoolInfo <TInvocation> pool = null;

            if (!dic.TryFindInTypeDictionarySearchSubTypes(key, out pool))
            {
                throw new InternalException("Could not find invocation base type " + key + ".");
            }
            return(pool);
        }
        protected TInvocation CreateInvocationBase <TInvocation>(DictionaryQuery <Type, InstancePoolInfo <TInvocation> > dic, Type key)
        {
            InstancePoolInfo <TInvocation> pool = this.FindPool <TInvocation>(key, dic);
            TInvocation result;

            if (!pool.Pool.TryTake(out result))
            {
                result = (TInvocation)this._modelInfo.Types.CompositeFactory.CreateInstance(pool.TypeGenerationResult.GeneratedTypeID, this._gArgs, new Object[] { this });
            }
            return(result);
        }
        /// <summary>
        /// Creates new instance of <see cref="ApplicationCodeResolveArgs"/>.
        /// </summary>
        /// <param name="genResults">Type generation results.</param>
        /// <param name="assemblies">A dictionary containing mapping from already-existing native assemblies and generated assemblies.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="genResults"/> or <paramref name="assemblies"/> is <c>null</c>.</exception>
        public ApplicationCodeResolveArgs(
            DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> genResults,
            DictionaryQuery <System.Reflection.Assembly, System.Reflection.Assembly> assemblies
            )
        {
            ArgumentValidator.ValidateNotNull("Generation results", genResults);
            ArgumentValidator.ValidateNotNull("Assemblies", assemblies);

            this._genResults = genResults;
            this._assemblies = assemblies;
        }
        public AbstractCompositeAssemblyDeclarationForExistingImpl(Assembler assembler, CompositeModelType compositeModelType, DictionaryQuery <Type, ListQuery <CompositeAssemblyInfo> > compositeAssemblyInfos)
        {
            ArgumentValidator.ValidateNotNull("Assembler", assembler);
            ArgumentValidator.ValidateNotNull("Assembly infos", compositeAssemblyInfos);
            ArgumentValidator.ValidateNotNull("Composite model type", compositeModelType);

            this._assembler          = assembler;
            this._compositeModelType = compositeModelType;
            this._composites         = compositeAssemblyInfos;
            this._affectedTypes      = new HashSet <Type>();
        }
        private void ProcessLayers(ApplicationValidationResultIQ validationResult, DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults, DictionaryProxy <LayerModel, LayerImpl> layers, LayerModel layerModel)
        {
            if (!layers.CQ.ContainsKey(layerModel))
            {
                layers.Add(layerModel, new LayerImpl(validationResult, loadingResults, this, layerModel));
            }

            foreach (LayerModel used in layerModel.UsedLayerModels)
            {
                this.ProcessLayers(validationResult, loadingResults, layers, used);
            }
        }
Beispiel #18
0
        static void PopulateDictionaryQuery()
        {
            using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("assembly"))
            {
                Debug.WriteLine("Adding assembly informations to 'assembly'.");

                Assembly a = Assembly.GetExecutingAssembly();
                dic.Add("Name", a.FullName);
                dic.Add("Version", a.GetName().Version.ToString());
                dic.Add("done", "");
            }
        }
        public StructureServiceProviderImpl(
            CompositeInstanceStructureOwner structure,
            DictionaryQuery <CompositeModelType, CompositeModelTypeInstanceScopeSupport> modelSupport,
            Func <Func <CompositeModel, Boolean>, IEnumerable <Tuple <CompositeInstanceStructureOwner, CompositeModel> > > serviceFinderFunction
            )
        {
            ArgumentValidator.ValidateNotNull("Structure", structure);
            ArgumentValidator.ValidateNotNull("Model type support", modelSupport);
            ArgumentValidator.ValidateNotNull("Service finder function", serviceFinderFunction);

            this._structure    = structure;
            this._modelSupport = modelSupport;
            this._modelFinder  = serviceFinderFunction;
        }
Beispiel #20
0
        public AssemblerImpl(ApplicationArchitecture <ApplicationModel <ApplicationSPI> > applicationArchitecture, Func <Int32> newCompositeIDRequestor, DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeSupport, UsesContainerMutable parentContainer, CollectionsFactory collectionsFactory)
        {
            ArgumentValidator.ValidateNotNull("Application architecture", applicationArchitecture);
            ArgumentValidator.ValidateNotNull("ID requestor function", newCompositeIDRequestor);
            ArgumentValidator.ValidateNotNull("Model type support", modelTypeSupport);
            ArgumentValidator.ValidateNotNull("Parent uses container", parentContainer);
            ArgumentValidator.ValidateNotNull("Collections factory", collectionsFactory);

            this._applicationArchitecture = applicationArchitecture;
            this._newCompositeIDRequestor = newCompositeIDRequestor;
            this._collectionsFactory      = collectionsFactory;
            this._compositeInfos          = this._collectionsFactory.NewDictionaryProxy <CompositeModelType, DictionaryWithRoles <Type, ListProxy <CompositeAssemblyInfo>, ListProxyQuery <CompositeAssemblyInfo>, ListQuery <CompositeAssemblyInfo> > >();
            this._assemblyScopeSupport    = modelTypeSupport;
            this._parentContainer         = parentContainer;
        }
Beispiel #21
0
        static void TestParallelModifications()
        {
            using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("parallel"))
            {
                dic.Add("hello", "world");
                dic["hello"].ShouldBe("world");

                using (DictionaryQuery <string> pdic = cx.DictionaryQuery <string>("parallel"))
                {
                    pdic["hello"] = "you";
                }

                dic.ShouldContainKey("hello");
                dic["hello"].ShouldBe("you");
                dic.Clear();
            }
        }
Beispiel #22
0
        internal ModuleArchitectureImpl(
            String moduleName,
            LayerArchitecture layer,
            UsesContainerQuery parentContainer,
            Func <Int32> compositeIDGenerator,
            DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeSupport
            )
        {
            ArgumentValidator.ValidateNotNull("Layer", layer);
            ArgumentValidator.ValidateNotNull("Parent meta-info container", parentContainer);

            this._moduleName = moduleName;
            this._layer      = layer;
            this._metaInfo   = UsesContainerMutableImpl.CreateWithParent(parentContainer);
            this._assembler  = new LayeredCompositeAssemblerImpl(this, compositeIDGenerator, modelTypeSupport, this._metaInfo, layer.Architecture.CollectionsFactory);
            this._domainSpecificAssemblers = new DomainSpecificAssemblerAggregatorImpl <LayeredCompositeAssembler>(layer.Architecture.CollectionsFactory);
        }
Beispiel #23
0
        internal LayeredApplicationModelImmutable(
            LayeredArchitecture architecture,
            Type genericCompositePropertyMixin,
            Type genericCompositeEventMixin,
            Type genericFragmentBaseType,
            DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeAssemblyScopeSupport,
            out DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport,
            out DictionaryProxy <Int32, CompositeModel> models,
            out ListProxy <LayerModelMutable> topLevelLayers,
            out ListProxy <LayerModelMutable> allLayers
            )
            : base(architecture, genericCompositePropertyMixin, genericCompositeEventMixin, genericFragmentBaseType, modelTypeAssemblyScopeSupport, out compositeModelTypeSupport, out models)
        {
            this._topLevelLayers = this.CollectionsFactory.NewListProxy <LayerModelMutable>();
            this._allLayers      = this.CollectionsFactory.NewListProxy <LayerModelMutable>();

            topLevelLayers = this._topLevelLayers;
            allLayers      = this._allLayers;
        }
Beispiel #24
0
        static void TestDictionaryQuery()
        {
            using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("assembly"))
            {
                dic.ShouldSatisfyAllConditions(
                    () => dic.ShouldContainKey("done"),
                    () => dic.ShouldContainKey("Name"),
                    () => dic["Name"].ShouldBe(Assembly.GetExecutingAssembly().FullName)
                    );

                dynamic dyn = dic.AsDynamic();
                (dyn.Name as object).ShouldBe(dic["Name"]);

                dyn.Name = Assembly.GetExecutingAssembly().GetName().Name;
                dic["Name"].ShouldBe(Assembly.GetExecutingAssembly().GetName().Name);

                dic["Name"] = Assembly.GetExecutingAssembly().FullName;
            }
        }
Beispiel #25
0
        static async Task TestMultithreading()
        {
            Random rand = new Random();

            using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("async"))
            {
                for (int i = 0; i < 15; i++)
                {
                    if (!dic.ContainsKey("nb" + i))
                    {
                        await Task.Delay(rand.Next(1000));

                        dic["nb" + i % 2] = "whatever" + i;
                    }
                }

                dic.Clear();
            }
        }
        protected ApplicationModelSkeletonImmutable(
            ApplicationArchitecture <ApplicationModel <ApplicationSPI> > architecture,
            Type genericCompositePropertyMixin,
            Type genericCompositeEventMixin,
            Type genericFragmentBaseType,
            DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeAssemblyScopeSupport,
            out DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport,
            out DictionaryProxy <Int32, CompositeModel> models
            )
        {
            ArgumentValidator.ValidateNotNull("Application architecture", architecture);
            ArgumentValidator.ValidateNotNull("Generic composite property mixin", genericCompositePropertyMixin);
            ArgumentValidator.ValidateNotNull("Generic composite event mixin", genericCompositeEventMixin);
            ArgumentValidator.ValidateNotNull("Generic fragment base type", genericFragmentBaseType);

            this._injectionService = new InjectionServiceImpl();
            this._genericCompositePropertyMixin = genericCompositePropertyMixin;
            this._genericCompositeEventMixin    = genericCompositeEventMixin;
            this._genericFragmentBaseType       = genericFragmentBaseType;
            this._collectionsFactory            = architecture.CollectionsFactory;
            this._compositeModelTypeSupport     = this._collectionsFactory.NewDictionaryProxy <CompositeModelType, CompositeModelTypeModelScopeSupport>(modelTypeAssemblyScopeSupport.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.CreateModelScopeSupport())).CQ;
            this._models              = this._collectionsFactory.NewDictionaryProxy <Int32, CompositeModel>();
            this._validationResult    = new Lazy <ApplicationValidationResultIQ>(this.DoValidate, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
            compositeModelTypeSupport = this._compositeModelTypeSupport;
            models             = this._models;
            this._typeModelDic = new Lazy <DictionaryQuery <CompositeModel, CompositeTypeModel> >(() =>
                                                                                                  this._collectionsFactory.NewDictionaryProxy(this.CompositeModels.Values
                                                                                                                                              .Select(cModel => Tuple.Create(cModel, ((CompositeValidationResultImmutable)this._validationResult.Value.CompositeValidationResults[cModel]).TypeModel))
                                                                                                                                              .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2, ReferenceEqualityComparer <CompositeModel> .ReferenceBasedComparer)).CQ
                                                                                                  , System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
            this._affectedAssemblies = new Lazy <SetQuery <Assembly> >(() =>
                                                                       this._collectionsFactory.NewSetProxy(new HashSet <Assembly>(
                                                                                                                this._typeModelDic.Value
                                                                                                                .SelectMany(tModel => tModel.Key.PublicTypes
                                                                                                                            .Concat(tModel.Value.PrivateCompositeTypeInfos.Keys)
                                                                                                                            .Concat(tModel.Value.FragmentTypeInfos.Keys)
                                                                                                                            .Concat(tModel.Value.ConcernInvocationTypeInfos.Keys)
                                                                                                                            .Concat(tModel.Value.SideEffectInvocationTypeInfos.Keys))
                                                                                                                .Select(type => type.GetAssembly())
                                                                                                                )).CQ
                                                                       , System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
        }
        internal SingletonApplicationModelImmutable(
            SingletonArchitecture architecture,
            Type genericCompositePropertyMixin,
            Type genericCompositeEventMixin,
            Type genericFragmentBaseType,
            DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeAssemblyScopeSupport,
            out DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport,
            out DictionaryProxy <Int32, CompositeModel> models,
            out SetProxy <CompositeModel> modelsForContainer,
            Assembler assembler
            )
            : base(architecture, genericCompositePropertyMixin, genericCompositeEventMixin, genericFragmentBaseType, modelTypeAssemblyScopeSupport, out compositeModelTypeSupport, out models)
        {
            ArgumentValidator.ValidateNotNull("Assembler", assembler);

            this._assembler       = assembler;
            this._compositeModels = this.CollectionsFactory.NewSetProxy <CompositeModel>();

            modelsForContainer = this._compositeModels;
        }
    /// <summary>
    /// Tries to find a value from <paramref name="dictionary"/> with types as keys. If direct lookup fails, this method will accept value of the key which will return <c>true</c> for <see cref="E_CommonUtils.IsAssignableFrom_IgnoreGenericArgumentsForGenericTypes"/> with <paramref name="type"/> as first argument and current key as second argument.
    /// </summary>
    /// <typeparam name="TValue">The type of the values of the <paramref name="dictionary"/>.</typeparam>
    /// <param name="type">The type to search value for.</param>
    /// <param name="dictionary">The dictionary to search from.</param>
    /// <param name="result">This will contain result if return value is <c>true</c>; otherwise <c>default(TValue)</c>.</param>
    /// <returns>If the dictionary contains key <paramref name="type"/> or any of its parent types, <c>true</c>; otherwise, <c>false</c>.</returns>
    internal static Boolean TryFindInTypeDictionarySearchSubTypes <TValue>(this DictionaryQuery <Type, TValue> dictionary, Type type, out TValue result)
    {
        // First try to find directly
        var found = dictionary.TryGetValue(type, out result);

        if (!found)
        {
            // Then iterate all value until found
            foreach (var kvp in dictionary)
            {
                found = type.IsAssignableFrom_IgnoreGenericArgumentsForGenericTypes(kvp.Key);
                if (found)
                {
                    result = kvp.Value;
                    break;
                }
            }
        }

        return(found);
    }
    /// <summary>
    /// Tries to find a value from <paramref name="dictionary"/> with types as keys. If direct lookup fails, this method will accept value of bottom-most type of <paramref name="type"/>'s inheritance hierarchy found in <paramref name="dictionary"/>.
    /// </summary>
    /// <typeparam name="TValue">The type of the values of the <paramref name="dictionary"/>.</typeparam>
    /// <param name="type">The type to search value for.</param>
    /// <param name="dictionary">The dictionary to search from.</param>
    /// <param name="result">This will contain result if return value is <c>true</c>; otherwise <c>default(TValue)</c>.</param>
    /// <returns>If the dictionary contains key <paramref name="type"/> or any of the keys has <paramref name="type"/> as its parent type, <c>true</c>; otherwise, <c>false</c>.</returns>
    internal static Boolean TryFindInTypeDictionarySearchBottommostType <TValue>(this DictionaryQuery <Type, TValue> dictionary, Type type, out TValue result)
    {
        var found = dictionary.TryGetValue(type, out result);

        if (!found)
        {
            // Search for bottom-most type
            var current   = type;
            var currentOK = false;
            foreach (var kvp in dictionary)
            {
                currentOK = current.IsAssignableFrom(kvp.Key);
                found     = currentOK || found;
                if (currentOK)
                {
                    result  = kvp.Value;
                    current = kvp.Key;
                }
            }
        }
        return(found);
    }
        public ModelInfoContainerImpl(
            DictionaryQuery <CompositeModelType, CompositeModelTypeInstanceScopeSupport> modelSupport,
            SetQuery <CompositeModel> models,
            ApplicationValidationResultIQ validationResult,
            DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults,
            CollectionsFactory collectionsFactory,
            Type genericPropertyMixinType,
            Type genericEventMixinType
            )
        {
            ArgumentValidator.ValidateNotNull("Model support", modelSupport);
            ArgumentValidator.ValidateNotNull("Models", models);
            ArgumentValidator.ValidateNotNull("Validation result", validationResult);

            PublicCompositeTypeGenerationResult[] typeGenResults = new PublicCompositeTypeGenerationResult[models.Count];
            Int32 gIdx = 0;

            foreach (CompositeModel model in models)
            {
                typeGenResults[gIdx] = loadingResults[model];
                ++gIdx;
            }

            this._compositeModels = collectionsFactory.NewDictionaryProxy <CompositeModelType, SetQuery <CompositeModelInfo> >(
                models
                .Select(model => model.ModelType)
                .Distinct()
                .ToDictionary(
                    modelType => modelType,
                    modelType2 =>
                    collectionsFactory.NewSetProxy <CompositeModelInfo>(new HashSet <CompositeModelInfo>(models
                                                                                                         .Select((modelInner, idx) => new KeyValuePair <CompositeModel, PublicCompositeTypeGenerationResult>(modelInner, typeGenResults[idx]))
                                                                                                         .Where(kvp => kvp.Key.ModelType.Equals(modelType2))
                                                                                                         .Select(kvp => new ModelInfoImpl(kvp.Key, kvp.Value, collectionsFactory)),
                                                                                                         ReferenceEqualityComparer <CompositeModelInfo> .ReferenceBasedComparer)).CQ
                    )
                ).CQ;
        }