Skip to content

Commit

Permalink
Add LanguagePreferencesService
Browse files Browse the repository at this point in the history
  • Loading branch information
cdorst committed Jan 30, 2024
1 parent 650611c commit 9ca6ba3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageVersion>1.1.0</PackageVersion>
<PackageVersion>1.2.0</PackageVersion>
<Description>Types for language preference options for BibleTalkAI.com</Description>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
6 changes: 6 additions & 0 deletions BibleTalkAI.LanguageOptions/ILanguagePreferencesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BibleTalkAI.LanguageOptions;

public interface ILanguagePreferencesService
{
LanguagePreference? GetLanguagePreference(int languagePreferenceOption);
}
13 changes: 13 additions & 0 deletions BibleTalkAI.LanguageOptions/LanguagePreferencesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace BibleTalkAI.LanguageOptions;

public class LanguagePreferencesService : ILanguagePreferencesService
{
public LanguagePreference? GetLanguagePreference(int languagePreferenceOption)
{
if (LanguagePreferences.Languages.TryGetValue(languagePreferenceOption, out LanguagePreference? languagePreference))
{
return languagePreference;
}
return null;
}
}
12 changes: 12 additions & 0 deletions BibleTalkAI.LanguageOptions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.Extensions.DependencyInjection;

namespace BibleTalkAI.LanguageOptions;

public static class ServiceCollectionExtensions
{
public static IServiceCollection AddLanguagePreferencesService(this IServiceCollection services)
{
services.AddSingleton<ILanguagePreferencesService, LanguagePreferencesService>();
return services;
}
}

0 comments on commit 9ca6ba3

Please sign in to comment.