예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var tempDataContext = new PtInMemoryContext();

            services.AddSingleton <IPtUserRepository, PtUserRepository>(c => new PtUserRepository(tempDataContext));
            services.AddSingleton <IPtItemsRepository, PtItemsRepository>(c => new PtItemsRepository(tempDataContext));
            services.AddSingleton <IPtDashboardRepository, PtDashboardRepository>(c => new PtDashboardRepository(tempDataContext));
            services.AddSingleton <IPtTasksRepository, PtTasksRepository>(c => new PtTasksRepository(tempDataContext));
            services.AddSingleton <IPtCommentsRepository, PtCommentsRepository>(c => new PtCommentsRepository(tempDataContext));

            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)
            .AddRazorPagesOptions(options =>
            {
                options.Conventions.AddPageRoute("/Dashboard", "");
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor();
            // services.AddSingleton<WeatherForecastService>();

            var tempDataContext = new PtInMemoryContext();

            services.AddSingleton <IPtUserRepository, PtUserRepository>(c => new PtUserRepository(tempDataContext));
            services.AddSingleton <IPtItemsRepository, PtItemsRepository>(c => new PtItemsRepository(tempDataContext));
            services.AddSingleton <IPtDashboardRepository, PtDashboardRepository>(c => new PtDashboardRepository(tempDataContext));
            services.AddSingleton <IPtTasksRepository, PtTasksRepository>(c => new PtTasksRepository(tempDataContext));
            services.AddSingleton <IPtCommentsRepository, PtCommentsRepository>(c => new PtCommentsRepository(tempDataContext));
        }
예제 #3
0
        public static void RegisterComponents()
        {
            var container = new UnityContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType<ITestService, TestService>();

            var tempDataContext = new PtInMemoryContext();

            container.RegisterType <IPtUserRepository, PtUserRepository>(
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(c => new PtUserRepository(tempDataContext))
                );

            container.RegisterType <IPtItemsRepository, PtItemsRepository>(
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(c => new PtItemsRepository(tempDataContext))
                );

            container.RegisterType <IPtDashboardRepository, PtDashboardRepository>(
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(c => new PtDashboardRepository(tempDataContext))
                );

            container.RegisterType <IPtTasksRepository, PtTasksRepository>(
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(c => new PtTasksRepository(tempDataContext))
                );

            container.RegisterType <IPtCommentsRepository, PtCommentsRepository>(
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(c => new PtCommentsRepository(tempDataContext))
                );


            container.Resolve <IPtItemsRepository>();
            container.Resolve <IPtUserRepository>();

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));
        }
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            builder.RootComponents.Add <App>("app");

            builder.Services.AddTransient(sp => new HttpClient {
                BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
            });

            var tempDataContext = new PtInMemoryContext();

            builder.Services.AddSingleton <IPtUserRepository, PtUserRepository>(c => new PtUserRepository(tempDataContext));
            builder.Services.AddSingleton <IPtItemsRepository, PtItemsRepository>(c => new PtItemsRepository(tempDataContext));
            builder.Services.AddSingleton <IPtDashboardRepository, PtDashboardRepository>(c => new PtDashboardRepository(tempDataContext));
            builder.Services.AddSingleton <IPtTasksRepository, PtTasksRepository>(c => new PtTasksRepository(tempDataContext));
            builder.Services.AddSingleton <IPtCommentsRepository, PtCommentsRepository>(c => new PtCommentsRepository(tempDataContext));

            await builder.Build().RunAsync();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var tempDataContext = new PtInMemoryContext();

            services.AddSingleton <IPtUserRepository, PtUserRepository>(c => new PtUserRepository(tempDataContext));
            services.AddSingleton <IPtItemsRepository, PtItemsRepository>(c => new PtItemsRepository(tempDataContext));
            services.AddSingleton <IPtDashboardRepository, PtDashboardRepository>(c => new PtDashboardRepository(tempDataContext));
            services.AddSingleton <IPtTasksRepository, PtTasksRepository>(c => new PtTasksRepository(tempDataContext));
            services.AddSingleton <IPtCommentsRepository, PtCommentsRepository>(c => new PtCommentsRepository(tempDataContext));


            services.AddRazorPages();
            services.AddMvc()
            .AddRazorPagesOptions(options =>
            {
                options.Conventions.AddPageRoute("/Dashboard", "");
            });

            services.AddKendo();
        }