public DefaultSpaBuilder(IAppBuilder applicationBuilder, SpaOptions options)
        {
            IAppBuilder applicationBuilder1 = applicationBuilder;

            if (applicationBuilder1 == null)
            {
                throw new ArgumentNullException(nameof(applicationBuilder));
            }
            this.ApplicationBuilder = applicationBuilder1;
            SpaOptions spaOptions = options;

            if (spaOptions == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            this.Options = spaOptions;
        }
示例#2
0
        /// <summary>
        /// Handles all requests from this point in the middleware chain by returning
        /// the default page for the Single Page Application (SPA).
        ///
        /// This middleware should be placed late in the chain, so that other middleware
        /// for serving static files, MVC actions, etc., takes precedence.
        /// </summary>
        /// <param name="app">The <see cref="IAppBuilder"/>.</param>
        /// <param name="configuration">
        /// This callback will be invoked so that additional middleware can be registered within
        /// the context of this SPA.
        /// </param>
        public static void UseSpa(this IAppBuilder app, Action <ISpaBuilder> configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            //Revisit: Use the options configured in DI (or blank if none was configured). We have to clone it
            // otherwise if you have multiple UseSpa calls, their configurations would interfere with one another.
            //var optionsProvider = app.ApplicationServices.GetService<IOptions<SpaOptions>>();
            //var options = new SpaOptions(optionsProvider.Value);

            var options    = new SpaOptions();
            var spaBuilder = new DefaultSpaBuilder(app, options);

            configuration.Invoke(spaBuilder);
            SpaDefaultPageMiddleware.Attach(spaBuilder);
        }
示例#3
0
 /// <summary>
 /// Constructs a new instance of <see cref="T:Microsoft.AspNetCore.SpaServices.SpaOptions" />.
 /// </summary>
 /// <param name="copyFromOptions">An instance of <see cref="T:Microsoft.AspNetCore.SpaServices.SpaOptions" /> from which values should be copied.</param>
 internal SpaOptions(SpaOptions copyFromOptions)
 {
     this._defaultPage = copyFromOptions.DefaultPage;
     this.DefaultPageStaticFileOptions = copyFromOptions.DefaultPageStaticFileOptions;
     this.SourcePath = copyFromOptions.SourcePath;
 }