예제 #1
0
파일: Program.cs 프로젝트: nojan1/WebTagger
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to WebTagger!");

            var arguments = ParseCommandLine(args);

            var configProvider = new ConfigurationProvider();

            foreach (var config in arguments.configurationFiles)
            {
                configProvider.AddConfigFile(config);
            }

            var containerBuilder = SetupIOC(configProvider);

            ConfigureLogging(configProvider);

            if (arguments.background)
            {
                QueryService.Init(configProvider, (services) =>
                {
                    containerBuilder.Populate(services);
                    ApplicationContainer = containerBuilder.Build();

                    return(ApplicationContainer);
                });
            }
            else
            {
                ApplicationContainer = containerBuilder.Build();
            }

            ApplicationContainer.Resolve <JobProcessor>().ProcessAllJobs(arguments.background).Wait();
        }
예제 #2
0
        public ApplicationContext Create(DbContextFactoryOptions options)
        {
            string connectionString = "";

            var location = Environment.GetEnvironmentVariable("DBLOCATION");

            if (string.IsNullOrEmpty(location))
            {
                var configurationProvider = new ConfigurationProvider();
                configurationProvider.AddConfigFile("config.json");

                connectionString = configurationProvider.ConnectionString;
            }
            else
            {
                connectionString = $"Filename={location}";
            }

            var optionsBuilder = new DbContextOptionsBuilder <ApplicationContext>();

            optionsBuilder.UseSqlite(connectionString);

            return(new ApplicationContext(optionsBuilder.Options));
        }