Example #1
0
 private Service(Dispatcher dispatcher)
 {
     Dispatcher = dispatcher;
     DBService = new LogDBService().Add(Tasks);
     var watch = new XIV.WatchService(Dispatcher).Add(Tasks);
     watch.LinkTo(DBService, false).Add(Tasks);
 }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                //options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDistributedMemoryCache();
            services.AddSession(options =>
            {
                // Sets session expiration to 20 minuates
                options.IdleTimeout     = TimeSpan.FromMinutes(20);
                options.Cookie.HttpOnly = true;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            string connectionString = Configuration.GetConnectionString("DefaultConnection");
            var    db = new VendingDBService(connectionString);
            //var db = new MockVendingDBService();
            var log = new LogDBService(connectionString);

            services.AddSingleton <IVendingMachine, VendingMachine>(m => new VendingMachine(db, log));
            services.AddScoped <IVendingService, VendingDBService>(m => new VendingDBService(connectionString));
            //services.AddScoped<IVendingService, MockVendingDBService>(m => new MockVendingDBService());
        }
        //[TestMethod]
        public void PopulateDatabase()
        {
            IVendingService db = new VendingDBService(_connectionString);
            //IVendingService db = new MockVendingDBService();

            //TestManager.PopulateDatabaseWithUsers(db);
            //TestManager.PopulateDatabaseWithInventory(db);
            //TestManager.PopulateDatabaseWithTransactions(db);

            ILogService log = new LogDBService(_connectionString);

            TestManager.PopulateLogFileWithOperations(db, log);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            string connectionString = Configuration.GetConnectionString("DefaultConnection");
            var    db = new VendingDBService(connectionString);
            //var db = new MockVendingDBService();
            var log = new LogDBService(connectionString);

            services.AddSingleton <IVendingMachine>(m => new VendingMachine(db, log));
        }
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("DefaultConnection");

            //var db = new VendingDBService(connectionString);
            var db = new MockVendingDBService();

            //var log = new LogFileService();
            var            log = new LogDBService(connectionString);
            VendingMachine vm  = new VendingMachine(db, log);
            VndrCLI        cli = new VndrCLI(vm);

            cli.Run();
        }