Exemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var remoteRazorLocationStore = new RemoteRazorLocationStore();

            remoteRazorLocationStore.LoadRemoteDataAsync("https://rawgit.com/ghstahl/asset-repo/master/aspnet-mvc5/views.json").GetAwaiter().GetResult();

            HostingEnvironment.RegisterVirtualPathProvider(new ViewPathProvider(remoteRazorLocationStore));

            var remoteStaticExternalSpaStore = new RemoteStaticExternalSpaStore(
                "https://rawgit.com/ghstahl/asset-repo/master/aspnet-mvc5/external.spa.config.json");
            var records = remoteStaticExternalSpaStore.GetRemoteDataAsync().GetAwaiter().GetResult();

            foreach (var spa in records.Spas)
            {
                remoteStaticExternalSpaStore.AddRecord(spa);
            }

            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterInstance(remoteStaticExternalSpaStore).As <IExternalSpaStore>();
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Exemplo n.º 2
0
        public async Task Invoke(CancellationToken cancellationToken)
        {
            var appConfig = new ExternalUrlsOptions();

            _config.GetSection("externalViews").Bind(appConfig);

            var urlViewSchema = await RemoteJsonFetch.GetRemoteJsonContentAsync(appConfig.UrlViewSchema);

            var remoteViewUrls = await GetRemoteUrlsAsync(appConfig.Urls, true);

            foreach (var url in remoteViewUrls.Urls)
            {
                await RemoteRazorLocationStore.LoadRemoteDataAsync(url, urlViewSchema);
            }
        }