//
// ServiceCollectionExtensions.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using NosSmooth.Data.Abstractions;
using NosSmooth.Data.Abstractions.Language;
namespace NosSmooth.Data.Database.Extensions;
///
/// Extension methods for .
///
public static class ServiceCollectionExtensions
{
///
/// Adds NosTale data language and info services using a database.
///
/// The service collection.
/// The collection.
public static IServiceCollection AddNostaleDataDatabase
(this IServiceCollection serviceCollection)
{
return serviceCollection
.AddSingleton()
.AddSingleton()
.AddDbContextFactory
(
(provider, builder) => builder.UseSqlite
(provider.GetRequiredService>().Value.ConnectionString)
);
}
///
/// Adds used for migrating data to the database.
///
/// The service collection.
/// The collection.
public static IServiceCollection AddNostaleDatabaseMigrator(this IServiceCollection serviceCollection)
{
return serviceCollection
.AddNostaleDataDatabase()
.AddSingleton();
}
}