using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using Syncfusion.Blazor;
namespace TestRazorLibrary.Helpers
{
public static class SyncfusionServices
{
public static IServiceCollection AddSyncfusionServices(this IServiceCollection services, bool DisableStaticAssetLoading = false)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
services.AddSyncfusionBlazor(DisableStaticAssetLoading);
return services;
}
}
}
|
//...
using TestRazorLibrary.Helpers;
namespace SyncBlazorApp
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// 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.AddSyncfusionServices();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//...
}
}
}
|
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using TestRazorLibrary.Helpers;
namespace BlazorWasmApp
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddSyncfusionServices();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
await builder.Build().RunAsync();
}
}
} |