Ejemplo n.º 1
0
        public DefaultSpaBuilder(IApplicationBuilder applicationBuilder, MulitSpaOptions options)
        {
            ApplicationBuilder = applicationBuilder
                                 ?? throw new ArgumentNullException(nameof(applicationBuilder));

            Options = options
                      ?? throw new ArgumentNullException(nameof(options));
        }
        /// <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="IApplicationBuilder"/>.</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 UseMulitSpa(this IApplicationBuilder app, Action <IMulitSpaBuilder> configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            // 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 <MulitSpaOptions> >();
            var options         = new MulitSpaOptions(optionsProvider.Value);

            var spaBuilder = new DefaultSpaBuilder(app, options);

            configuration.Invoke(spaBuilder);
            SpaDefaultPageMiddleware.Attach(spaBuilder);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs a new instance of <see cref="MulitSpaOptions"/>.
 /// </summary>
 /// <param name="copyFromOptions">An instance of <see cref="MulitSpaOptions"/> from which values should be copied.</param>
 internal MulitSpaOptions(MulitSpaOptions copyFromOptions)
 {
     _defaultPage = copyFromOptions.DefaultPage;
     DefaultPageStaticFileOptions = copyFromOptions.DefaultPageStaticFileOptions;
     SourcePath = copyFromOptions.SourcePath;
 }