//
// 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.Extensions.DependencyInjection;
using NosSmooth.Data.Abstractions;
using NosSmooth.Data.Abstractions.Language;
using NosSmooth.Data.NOSFiles.Readers;
using NosSmooth.Data.NOSFiles.Readers.Types;
namespace NosSmooth.Data.NOSFiles.Extensions;
///
/// Extension methods for .
///
public static class ServiceCollectionExtensions
{
///
/// Adds the nostale file data info and language service.
///
/// The service collection.
/// The collection.
public static IServiceCollection AddNostaleDataFiles(this IServiceCollection serviceCollection)
{
return serviceCollection
.AddNostaleDataParsing()
.AddSingleton()
.AddSingleton(p => p.GetRequiredService().InfoService)
.AddSingleton(p => p.GetRequiredService().LanguageService);
}
///
/// Adds the .
///
/// The service collection.
/// The collection.
public static IServiceCollection AddNostaleDataParsing(this IServiceCollection serviceCollection)
{
return serviceCollection
.AddFileReader()
.AddSingleton();
}
///
/// Add the file reader and NosTale type readers.
///
/// The service collection.
/// The collection.
public static IServiceCollection AddFileReader(this IServiceCollection serviceCollection)
{
return serviceCollection
.AddSingleton()
.AddFileTypeReader()
.AddFileTypeReader();
}
///
/// Add the given file type reader.
///
/// The service collection.
/// The type of the reader.
/// The collection.
public static IServiceCollection AddFileTypeReader(this IServiceCollection serviceCollection)
where TTypeReader : class, IFileTypeReader
{
return serviceCollection.AddSingleton();
}
}