コード例 #1
0
ファイル: NasEngine.cs プロジェクト: vic0626/nas-merk
        /// <summary>
        /// Initialize components and plugins in the Nas environment.
        /// </summary>
        /// <param name="config">Config</param>
        public void Initialize(NasConfig config)
        {
            bool databaseInstalled = DataSettingsHelper.DatabaseIsInstalled();

            if (databaseInstalled)
            {
                //startup tasks
                RunStartupTasks();
            }
        }
コード例 #2
0
ファイル: EngineContext.cs プロジェクト: vic0626/nas-merk
        /// <summary>
        /// Creates a factory instance and adds a http application injecting facility.
        /// </summary>
        /// <returns>A new factory</returns>
        public static IEngine CreateEngineInstance(NasConfig config)
        {
            if (config != null && !string.IsNullOrEmpty(config.EngineType))
            {
                var engineType = Type.GetType(config.EngineType);
                if (engineType == null)
                {
                    throw new ConfigurationErrorsException("The type '" + engineType + "' could not be found. Please check the configuration at /configuration/Nas/engine[@engineType] or check for missing assemblies.");
                }
                if (!typeof(IEngine).IsAssignableFrom(engineType))
                {
                    throw new ConfigurationErrorsException("The type '" + engineType + "' doesn't implement 'Nas.Core.Infrastructure.IEngine' and cannot be configured in /configuration/Nas/engine[@engineType] for that purpose.");
                }
                return(Activator.CreateInstance(engineType) as IEngine);
            }

            return(new NasEngine());
        }
コード例 #3
0
ファイル: NasEngine.cs プロジェクト: vic0626/nas-merk
        private void InitializeContainer(ContainerConfigurer configurer, EventBroker broker, NasConfig config)
        {
            var builder = new ContainerBuilder();

            _containerManager = new ContainerManager(builder.Build());
            configurer.Configure(this, _containerManager, broker, config);
        }
コード例 #4
0
        public UpdateServiceRequest(string serviceName, string description = "", string role = null, LogConfig logConfig = null,
                                    bool internetAccess = true, VpcConfig vpcConfig          = null, NasConfig nasConfig = null, Dictionary <string, string> customHeaders = null)
        {
            Contract.Requires(string.IsNullOrEmpty(serviceName) == false);
            this.ServiceName       = serviceName;
            this.UpdateServiceMeta = new UpdateServiceMeta(description, role, logConfig, internetAccess, vpcConfig, nasConfig);

            this.Headers = customHeaders;
        }
コード例 #5
0
        public virtual void Configure(IEngine engine, ContainerManager containerManager, EventBroker broker, NasConfig configuration)
        {
            //other dependencies
            containerManager.AddComponentInstance <NasConfig>(configuration, "Nas.configuration");
            containerManager.AddComponentInstance <IEngine>(engine, "Nas.engine");
            containerManager.AddComponentInstance <ContainerConfigurer>(this, "Nas.containerConfigurer");

            //type finder
            containerManager.AddComponent <ITypeFinder, WebAppTypeFinder>("Nas.typeFinder");

            //register dependencies provided by other assemblies
            var typeFinder = containerManager.Resolve <ITypeFinder>();

            containerManager.UpdateContainer(x =>
            {
                var drTypes     = typeFinder.FindClassesOfType <IDependencyRegistrar>();
                var drInstances = new List <IDependencyRegistrar>();
                foreach (var drType in drTypes)
                {
                    drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType));
                }
                //sort
                drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList();
                foreach (var dependencyRegistrar in drInstances)
                {
                    dependencyRegistrar.Register(x, typeFinder);
                }
            });

            //event broker
            containerManager.AddComponentInstance(broker);
        }
コード例 #6
0
ファイル: ThemeProvider.cs プロジェクト: vic0626/nas-merk
 public ThemeProvider(NasConfig NasConfig, IWebHelper webHelper)
 {
     basePath = webHelper.MapPath(NasConfig.ThemeBasePath);
     LoadConfigurations();
 }