From b1ef62d782bf52ad1f7cbe74fbfc4f041a031a2f Mon Sep 17 00:00:00 2001 From: mustiks Date: Thu, 1 Feb 2024 17:41:21 +0300 Subject: [PATCH] add dependency injection --- ...trovich.Extensions.DependencyInjection.csproj | 16 ++++++++++++++++ .../ServiceCollectionExtensions.cs | 12 ++++++++++++ src/NPetrovich.sln | 6 ++++++ src/NPetrovich/IPetrovich.cs | 13 +++++++++++++ src/NPetrovich/Petrovich.cs | 2 +- 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/NPetrovich.Extensions.DependencyInjection/NPetrovich.Extensions.DependencyInjection.csproj create mode 100644 src/NPetrovich.Extensions.DependencyInjection/ServiceCollectionExtensions.cs create mode 100644 src/NPetrovich/IPetrovich.cs diff --git a/src/NPetrovich.Extensions.DependencyInjection/NPetrovich.Extensions.DependencyInjection.csproj b/src/NPetrovich.Extensions.DependencyInjection/NPetrovich.Extensions.DependencyInjection.csproj new file mode 100644 index 0000000..c22b6d8 --- /dev/null +++ b/src/NPetrovich.Extensions.DependencyInjection/NPetrovich.Extensions.DependencyInjection.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + NPetrovich.Extensions.DependencyInjection + + + + + + + + + + + diff --git a/src/NPetrovich.Extensions.DependencyInjection/ServiceCollectionExtensions.cs b/src/NPetrovich.Extensions.DependencyInjection/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..045fe5c --- /dev/null +++ b/src/NPetrovich.Extensions.DependencyInjection/ServiceCollectionExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace NPetrovich.Extensions.DependencyInjection +{ + public static class ServiceCollectionExtensions + { + public static IServiceCollection AddPetrovich(this IServiceCollection services) + { + return services.AddSingleton(); + } + } +} \ No newline at end of file diff --git a/src/NPetrovich.sln b/src/NPetrovich.sln index f55dfc0..3a479b4 100644 --- a/src/NPetrovich.sln +++ b/src/NPetrovich.sln @@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPetrovich.Eval", "NPetrovi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPetrovich.Tests", "NPetrovich.Tests\NPetrovich.Tests.csproj", "{C3B84DDA-5D07-48F3-BFF6-65BE46BA1DC7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPetrovich.Extensions.DependencyInjection", "NPetrovich.Extensions.DependencyInjection\NPetrovich.Extensions.DependencyInjection.csproj", "{1FF3E1EC-3EFD-47D2-81CF-AE3790DFBFA7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,5 +26,9 @@ Global {C3B84DDA-5D07-48F3-BFF6-65BE46BA1DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU {C3B84DDA-5D07-48F3-BFF6-65BE46BA1DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU {C3B84DDA-5D07-48F3-BFF6-65BE46BA1DC7}.Release|Any CPU.Build.0 = Release|Any CPU + {1FF3E1EC-3EFD-47D2-81CF-AE3790DFBFA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1FF3E1EC-3EFD-47D2-81CF-AE3790DFBFA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1FF3E1EC-3EFD-47D2-81CF-AE3790DFBFA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1FF3E1EC-3EFD-47D2-81CF-AE3790DFBFA7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/NPetrovich/IPetrovich.cs b/src/NPetrovich/IPetrovich.cs new file mode 100644 index 0000000..5e5a585 --- /dev/null +++ b/src/NPetrovich/IPetrovich.cs @@ -0,0 +1,13 @@ +namespace NPetrovich +{ + public interface IPetrovich : IFio + { + bool AutoDetectGender { get; set; } + Gender Gender { get; set; } + Petrovich InflectTo(Case @case); + string InflectFirstNameTo(Case @case); + string InflectLastNameTo(Case @case); + string InflectMiddleNameTo(Case @case); + string ToString(); + } +} diff --git a/src/NPetrovich/Petrovich.cs b/src/NPetrovich/Petrovich.cs index bb38f30..b574e81 100644 --- a/src/NPetrovich/Petrovich.cs +++ b/src/NPetrovich/Petrovich.cs @@ -6,7 +6,7 @@ namespace NPetrovich { - public class Petrovich : IFio + public class Petrovich : IPetrovich { private readonly RulesProvider _provider; private readonly GenderDeterminator _genderDeterminator;