Skip to content

Commit

Permalink
add dependency injection
Browse files Browse the repository at this point in the history
  • Loading branch information
mustiks committed Feb 1, 2024
1 parent 2221f71 commit b1ef62d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>NPetrovich.Extensions.DependencyInjection</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NPetrovich\NPetrovich.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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<IPetrovich, Petrovich>();
}
}
}
6 changes: 6 additions & 0 deletions src/NPetrovich.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
13 changes: 13 additions & 0 deletions src/NPetrovich/IPetrovich.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
2 changes: 1 addition & 1 deletion src/NPetrovich/Petrovich.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace NPetrovich
{
public class Petrovich : IFio
public class Petrovich : IPetrovich
{
private readonly RulesProvider _provider;
private readonly GenderDeterminator _genderDeterminator;
Expand Down

0 comments on commit b1ef62d

Please sign in to comment.