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) }); builder.Services.AddSingleton <IAssetsResolver, AssetsResolver>(); builder.Services.AddSingleton <IAssetLoader <Sprite>, SpriteAssetLoader>(); builder.Services.AddSingleton <IAssetLoader <AnimationCollection>, AnimationsAssetLoader>(); builder.Services.AddSingleton <IAssetLoader <SpriteSheet>, SpriteSheetAssetLoader>(); builder.Services.AddSingleton <IAssetLoader <Sound>, SoundAssetLoader>(); builder.Services.AddSingleton <IAssetLoader <MapObjects>, MapObjectsLoader>(); builder.Services.AddSingleton <IAssetLoaderFactory>(ctx => { var factory = new AssetLoaderFactory(); factory.Register(ctx.GetRequiredService <IAssetLoader <Sprite> >()); factory.Register(ctx.GetRequiredService <IAssetLoader <SpriteSheet> >()); factory.Register(ctx.GetRequiredService <IAssetLoader <AnimationCollection> >()); factory.Register(ctx.GetRequiredService <IAssetLoader <Sound> >()); factory.Register(ctx.GetRequiredService <IAssetLoader <MapObjects> >()); return(factory); }); await builder.Build().RunAsync(); }
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) }); builder.Services.AddSingleton <IAssetsResolver, AssetsResolver>(); builder.Services.AddSingleton <IAssetLoader <Sprite>, SpriteAssetLoader>(); builder.Services.AddSingleton <IAssetLoaderFactory>(ctx => { var factory = new AssetLoaderFactory(); var spriteLoader = ctx.GetService <IAssetLoader <Sprite> >(); factory.Register(spriteLoader); return(factory); }); await builder.Build().RunAsync(); }