示例#1
0
        static void Main(string[] args)
        {
            FakeDB.InitializeData();
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IPrinter, Printer>();


            var serviceProvider = serviceCollection.BuildServiceProvider();
            var printer         = serviceProvider.GetRequiredService <IPrinter>();

            printer.StartUI();
        }
        private void ChangeToMainView()
        {
            FakeDB.InitializeData();
            ServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IOwnerRepository, OwnerRepository>();
            serviceCollection.AddScoped <IOwnerService, OwnerService>();
            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IView, PetView>();
            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
            IView           petView         = serviceProvider.GetRequiredService <IView>();

            petView.Initialize();
        }
        static void Main()
        {
            Console.Title = "NEKO-PetShop";
            FakeDB.InitializeData();

            ServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IOwnerRepository, OwnerRepository>();
            serviceCollection.AddScoped <IOwnerService, OwnerService>();
            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IView, StartUpView>();
            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
            IView           startUpView     = serviceProvider.GetRequiredService <IView>();

            startUpView.Initialize();
        }
示例#4
0
 public Startup(IConfiguration configuration)
 {
     FakeDB.InitializeData();
     Configuration = configuration;
 }