// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var repo = new MemoryRepository(); repo.AddUser("admin", "1234"); repo.AddUser("dummy", "password"); var library = new MemorySongLibrary(new List <Song>() { new Song("Lovelove", "Love first", "Love me now"), new Song("Badass Inc.", "That's a bad ass", "I want ass") }); ApiConfiguration.UserRepository = repo; ApiConfiguration.SongLibrary = library; services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("#app"); //JukeController.Instance.Player.RegisterPlayerEngine(new CorePlayerEngine()); var task = JukeController.Instance.LoadHandler.LoadSongs(new XmlSongReader("library.xml")); var memorySongLibrary = new MemorySongLibrary(new List <ApiSong> { new ApiSong("artist 1", "Album 1", "My song"), new ApiSong("artist 1", "Album 1", "My song 2"), new ApiSong("artist 1", "Album 1", "My song 3") }); var memoryRepository = new MemoryRepository(); memoryRepository.AddUser("user", "user"); ApiConfiguration.SongLibrary = new LocalSongLibrary(JukeController.Instance.Browser); ApiConfiguration.UserRepository = memoryRepository; builder.Services.AddScoped( sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); var userSession = new UserSession(); builder.Services.AddScoped(s => userSession); builder.Services.AddSingleton(userSession); builder.Services.AddScoped( jk => new LibraryApi()); builder.Services.AddScoped( jk => new LoginApi()); await task; await builder.Build().RunAsync(); }