@@ -4741,6 +4741,71 @@ To run the above code, the following NuGet packages must be added:
47414741> [ !NOTE]
47424742> Overriding BCL bindings allows you to provide custom implementations for standard types, enabling specialized behavior for your application.
47434743
4744+ ## Default BCL bindings
4745+
4746+ Pure.DI provides default bindings for commonly used .NET BCL types, so they can be injected without extra setup code.
4747+
4748+ ``` c#
4749+ using Shouldly ;
4750+ using Pure .DI ;
4751+ using System .Globalization ;
4752+ using System .Security .Cryptography ;
4753+
4754+ DI .Setup (nameof (Composition ))
4755+ .Root <ReportService >(" ReportService" );
4756+
4757+ var composition = new Composition ();
4758+ var reportService = composition .ReportService ;
4759+
4760+ reportService .Culture .ShouldBe (CultureInfo .CurrentCulture );
4761+ reportService .FormatProvider .ShouldBe (reportService .Culture );
4762+ reportService .CompareInfo .ShouldBe (CultureInfo .CurrentCulture .CompareInfo );
4763+ reportService .StringComparer .ShouldBe (StringComparer .Ordinal );
4764+ reportService .StringComparison .ShouldBe (StringComparison .Ordinal );
4765+ reportService .TimeProvider .ShouldBe (TimeProvider .System );
4766+ reportService .Completion .Task .CreationOptions
4767+ .HasFlag (TaskCreationOptions .RunContinuationsAsynchronously )
4768+ .ShouldBeTrue ();
4769+
4770+ var bytes = new byte [4 ];
4771+ reportService .RandomNumberGenerator .GetBytes (bytes );
4772+ bytes .Length .ShouldBe (4 );
4773+
4774+ class ReportService (
4775+ CultureInfo culture ,
4776+ IFormatProvider formatProvider ,
4777+ CompareInfo compareInfo ,
4778+ StringComparer stringComparer ,
4779+ StringComparison stringComparison ,
4780+ TimeProvider timeProvider ,
4781+ TaskCompletionSource <string > completion ,
4782+ RandomNumberGenerator randomNumberGenerator )
4783+ {
4784+ public CultureInfo Culture { get ; } = culture ;
4785+
4786+ public IFormatProvider FormatProvider { get ; } = formatProvider ;
4787+
4788+ public CompareInfo CompareInfo { get ; } = compareInfo ;
4789+
4790+ public StringComparer StringComparer { get ; } = stringComparer ;
4791+
4792+ public StringComparison StringComparison { get ; } = stringComparison ;
4793+
4794+ public TimeProvider TimeProvider { get ; } = timeProvider ;
4795+
4796+ public TaskCompletionSource <string > Completion { get ; } = completion ;
4797+
4798+ public RandomNumberGenerator RandomNumberGenerator { get ; } = randomNumberGenerator ;
4799+ }
4800+ ```
4801+
4802+ To run the above code, the following NuGet packages must be added:
4803+ - [ Pure.DI] ( https://www.nuget.org/packages/Pure.DI )
4804+ - [ Shouldly] ( https://www.nuget.org/packages/Shouldly )
4805+
4806+ > [ !NOTE]
4807+ > Default BCL bindings can still be overridden in the composition when an application needs a different policy.
4808+
47444809## Generics
47454810
47464811Generic types are also supported.
@@ -11245,7 +11310,7 @@ The [project file](/samples/AvaloniaApp/AvaloniaApp.csproj) looks like this:
1124511310<Project Sdk =" Microsoft.NET.Sdk" >
1124611311 ...
1124711312 <ItemGroup >
11248- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11313+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1124911314 <PrivateAssets >all</PrivateAssets >
1125011315 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1125111316 </PackageReference >
@@ -11316,11 +11381,11 @@ The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like t
1131611381<Project Sdk =" Microsoft.NET.Sdk.Web" >
1131711382 ...
1131811383 <ItemGroup >
11319- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11384+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1132011385 <PrivateAssets >all</PrivateAssets >
1132111386 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1132211387 </PackageReference >
11323- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
11388+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1132411389 </ItemGroup >
1132511390
1132611391</Project >
@@ -11398,11 +11463,11 @@ The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) lo
1139811463<Project Sdk =" Microsoft.NET.Sdk.Web" >
1139911464 ...
1140011465 <ItemGroup >
11401- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11466+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1140211467 <PrivateAssets >all</PrivateAssets >
1140311468 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1140411469 </PackageReference >
11405- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
11470+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1140611471 </ItemGroup >
1140711472
1140811473</Project >
@@ -11496,7 +11561,7 @@ The [project file](/samples/ShroedingersCatNativeAOT/ShroedingersCatNativeAOT.cs
1149611561 <RuntimeIdentifier >win-x64</RuntimeIdentifier >
1149711562 </PropertyGroup >
1149811563 <ItemGroup >
11499- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11564+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1150011565 <PrivateAssets >all</PrivateAssets >
1150111566 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1150211567 </PackageReference >
@@ -11599,7 +11664,7 @@ The [project file](/samples/ShroedingersCat/ShroedingersCat.csproj) looks like t
1159911664<Project Sdk =" Microsoft.NET.Sdk" >
1160011665 ...
1160111666 <ItemGroup >
11602- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11667+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1160311668 <PrivateAssets >all</PrivateAssets >
1160411669 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1160511670 </PackageReference >
@@ -11688,7 +11753,7 @@ The [project file](/samples/ShroedingersCatTopLevelStatements/ShroedingersCatTop
1168811753<Project Sdk =" Microsoft.NET.Sdk" >
1168911754 ...
1169011755 <ItemGroup >
11691- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11756+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1169211757 <PrivateAssets >all</PrivateAssets >
1169311758 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1169411759 </PackageReference >
@@ -11796,11 +11861,11 @@ The [project file](/samples/EF/EF.csproj) looks like this:
1179611861<Project Sdk =" Microsoft.NET.Sdk" >
1179711862 ...
1179811863 <ItemGroup >
11799- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11864+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1180011865 <PrivateAssets >all</PrivateAssets >
1180111866 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1180211867 </PackageReference >
11803- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
11868+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1180411869 </ItemGroup >
1180511870
1180611871</Project >
@@ -11871,11 +11936,11 @@ The [project file](/samples/GrpcService/GrpcService.csproj) looks like this:
1187111936<Project Sdk =" Microsoft.NET.Sdk.Web" >
1187211937 ...
1187311938 <ItemGroup >
11874- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
11939+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1187511940 <PrivateAssets >all</PrivateAssets >
1187611941 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1187711942 </PackageReference >
11878- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
11943+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1187911944 </ItemGroup >
1188011945
1188111946</Project >
@@ -12042,11 +12107,11 @@ The [project file](/samples/MAUIApp/MAUIApp.csproj) looks like this:
1204212107<Project Sdk =" Microsoft.NET.Sdk" >
1204312108 ...
1204412109 <ItemGroup >
12045- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
12110+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1204612111 <PrivateAssets >all</PrivateAssets >
1204712112 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1204812113 </PackageReference >
12049- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
12114+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1205012115 </ItemGroup >
1205112116
1205212117</Project >
@@ -12142,11 +12207,11 @@ The [project file](/samples/MinimalWebAPI/MinimalWebAPI.csproj) looks like this:
1214212207<Project Sdk =" Microsoft.NET.Sdk.Web" >
1214312208 ...
1214412209 <ItemGroup >
12145- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
12210+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1214612211 <PrivateAssets >all</PrivateAssets >
1214712212 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1214812213 </PackageReference >
12149- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
12214+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1215012215 </ItemGroup >
1215112216
1215212217</Project >
@@ -12353,11 +12418,11 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this:
1235312418<Project Sdk =" Microsoft.NET.Sdk.Web" >
1235412419 ...
1235512420 <ItemGroup >
12356- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
12421+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1235712422 <PrivateAssets >all</PrivateAssets >
1235812423 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1235912424 </PackageReference >
12360- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
12425+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1236112426 </ItemGroup >
1236212427
1236312428</Project >
@@ -12429,11 +12494,11 @@ The [project file](/samples/WebApp/WebApp.csproj) looks like this:
1242912494<Project Sdk =" Microsoft.NET.Sdk.Web" >
1243012495 ...
1243112496 <ItemGroup >
12432- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
12497+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1243312498 <PrivateAssets >all</PrivateAssets >
1243412499 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1243512500 </PackageReference >
12436- <PackageReference Include =" Pure.DI.MS" Version =" 2.4.2 " />
12501+ <PackageReference Include =" Pure.DI.MS" Version =" 2.4.3 " />
1243712502 </ItemGroup >
1243812503
1243912504</Project >
@@ -12509,7 +12574,7 @@ The [project file](/samples/WinFormsAppNetCore/WinFormsAppNetCore.csproj) looks
1250912574<Project Sdk =" Microsoft.NET.Sdk" >
1251012575 ...
1251112576 <ItemGroup >
12512- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
12577+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1251312578 <PrivateAssets >all</PrivateAssets >
1251412579 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1251512580 </PackageReference >
@@ -12590,7 +12655,7 @@ The [project file](/samples/WinFormsApp/WinFormsApp.csproj) looks like this:
1259012655<Project ToolsVersion =" 15.0" xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
1259112656 ...
1259212657 <ItemGroup >
12593- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
12658+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1259412659 <PrivateAssets >all</PrivateAssets >
1259512660 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1259612661 </PackageReference >
@@ -12709,7 +12774,7 @@ The [project file](/samples/WpfAppNetCore/WpfAppNetCore.csproj) looks like this:
1270912774<Project Sdk =" Microsoft.NET.Sdk" >
1271012775 ...
1271112776 <ItemGroup >
12712- <PackageReference Include =" Pure.DI" Version =" 2.4.2 " >
12777+ <PackageReference Include =" Pure.DI" Version =" 2.4.3 " >
1271312778 <PrivateAssets >all</PrivateAssets >
1271412779 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1271512780 </PackageReference >
0 commit comments