示例#1
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            private IEnumerable <IFeatureLoader> GetKernelDefaultFeatureLoaders()
            {
                var kernelModuleConfig = new MicroserviceConfig.ModuleConfig()
                {
                    Assembly = typeof(MicroserviceHost).GetTypeInfo().Assembly.GetName().Name
                };

                return(GetFeatureLoadersByModuleConfigs(kernelModuleConfig));
            }
示例#2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private void EnsureFeatureListed(Type featureLoaderType, MicroserviceConfig.ModuleConfig moduleConfig)
        {
            var namedFeatureAttribute = featureLoaderType.GetTypeInfo().GetCustomAttribute <FeatureLoaderAttribute>();

            if (namedFeatureAttribute != null)
            {
                var feature = moduleConfig.Features.FirstOrDefault(f => f.Name == namedFeatureAttribute.Name);

                if (feature == null)
                {
                    moduleConfig.Features = moduleConfig.Features.Append(new MicroserviceConfig.ModuleConfig.FeatureConfig()
                    {
                        Name = namedFeatureAttribute.Name
                    }).ToArray();
                }
            }
        }
示例#3
0
            ////-------------------------------------------------------------------------------------------------------------------------------------------------

            //private void CompileComponents(List<IFeatureLoader> featureLoaders)
            //{
            //    featureLoaders.ForEach(x => x.CompileComponents(OwnerHost.Container));

            //    var typeLibrary = OwnerHost.Container.Resolve<ITypeLibrary<IRuntimeTypeFactoryArtifact>>();
            //    typeLibrary.CompileDeclaredTypeMembers();

            //    var compiledComponents = CreateComponentContainerBuilder();

            //    featureLoaders.ForEach(x => x.ContributeCompiledComponents(OwnerHost.Container, compiledComponents));

            //    OwnerHost.Container.Merge(compiledComponents);
            //}

            //-------------------------------------------------------------------------------------------------------------------------------------------------

            private List <IFeatureLoader> GetConfiguredFeatureLoaders()
            {
                var featureLoaders = new List <IFeatureLoader>();

                var kernelAssembly = typeof(MicroserviceHost).GetTypeInfo().Assembly.GetName().Name;

                if (!OwnerHost.BootConfig.MicroserviceConfig.FrameworkModules.Any(x => x.Assembly == kernelAssembly))
                {
                    var kernelModuleConfig = new MicroserviceConfig.ModuleConfig()
                    {
                        Assembly = kernelAssembly
                    };
                    featureLoaders.AddRange(GetFeatureLoadersByModuleConfigs(kernelModuleConfig));
                }

                featureLoaders.AddRange(GetFeatureLoadersByModuleConfigs(OwnerHost.BootConfig.MicroserviceConfig.FrameworkModules));
                featureLoaders.AddRange(GetFeatureLoadersByModuleConfigs(OwnerHost.BootConfig.MicroserviceConfig.ApplicationModules));

                return(featureLoaders);
            }
示例#4
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private MicroserviceConfig.ModuleConfig[] EnsureModuleListed(
            Type typeFromModuleAssembly,
            MicroserviceConfig.ModuleConfig[] moduleList,
            out MicroserviceConfig.ModuleConfig module)
        {
            var assemblyName = typeFromModuleAssembly.GetTypeInfo().Assembly.GetName().Name;

            module = moduleList.FirstOrDefault(m => m.Assembly.Equals(assemblyName, StringComparison.OrdinalIgnoreCase));

            if (module != null)
            {
                return(moduleList);
            }

            module = new MicroserviceConfig.ModuleConfig {
                Assembly = assemblyName,
                Features = Array.Empty <MicroserviceConfig.ModuleConfig.FeatureConfig>()
            };

            return(moduleList.Append(module).ToArray());
        }