~ruther/NosSmooth

b86adad490713a7dd73100e905c4df4b664c1707 — František Boháček 3 years ago 9bb918f
feat(data): add nostale data files service collection extensions
1 files changed, 28 insertions(+), 0 deletions(-)

M Data/NosSmooth.Data.NOSFiles/Extensions/ServiceCollectionExtensions.cs
M Data/NosSmooth.Data.NOSFiles/Extensions/ServiceCollectionExtensions.cs => Data/NosSmooth.Data.NOSFiles/Extensions/ServiceCollectionExtensions.cs +28 -0
@@ 5,6 5,8 @@
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Extensions.DependencyInjection;
using NosSmooth.Data.Abstractions;
using NosSmooth.Data.Abstractions.Language;
using NosSmooth.Data.NOSFiles.Readers;
using NosSmooth.Data.NOSFiles.Readers.Types;



@@ 16,6 18,32 @@ namespace NosSmooth.Data.NOSFiles.Extensions;
public static class ServiceCollectionExtensions
{
    /// <summary>
    /// Adds the nostale file data info and language service.
    /// </summary>
    /// <param name="serviceCollection">The service collection.</param>
    /// <returns>The collection.</returns>
    public static IServiceCollection AddNostaleDataFiles(this IServiceCollection serviceCollection)
    {
        return serviceCollection
            .AddNostaleDataParsing()
            .AddSingleton<NostaleDataFilesManager>()
            .AddSingleton<IInfoService>(p => p.GetRequiredService<NostaleDataFilesManager>().InfoService)
            .AddSingleton<ILanguageService>(p => p.GetRequiredService<NostaleDataFilesManager>().LanguageService);
    }

    /// <summary>
    /// Adds the <see cref="NostaleDataParser"/>.
    /// </summary>
    /// <param name="serviceCollection">The service collection.</param>
    /// <returns>The collection.</returns>
    public static IServiceCollection AddNostaleDataParsing(this IServiceCollection serviceCollection)
    {
        return serviceCollection
            .AddFileReader()
            .AddSingleton<NostaleDataParser>();
    }

    /// <summary>
    /// Add the file reader and NosTale type readers.
    /// </summary>
    /// <param name="serviceCollection">The service collection.</param>

Do not follow this link