Skip to content

Commit e733591

Browse files
Update samples
1 parent f5f15cc commit e733591

334 files changed

Lines changed: 4055 additions & 3840 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AI_CONTEXT_LARGE.md

Lines changed: 270 additions & 402 deletions
Large diffs are not rendered by default.

Pure.DI.sln

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "readme", "readme", "{24E449
7979
readme\HeaderTemplate.md = readme\HeaderTemplate.md
8080
readme\ContributingTemplate.md = readme\ContributingTemplate.md
8181
readme\UnityPageTemplate.md = readme\UnityPageTemplate.md
82-
AI_CONTEXT_LARGE.md = AI_CONTEXT_LARGE.md
83-
AI_CONTEXT_MEDIUM.md = AI_CONTEXT_MEDIUM.md
84-
AI_CONTEXT_SMALL.md = AI_CONTEXT_SMALL.md
8582
EndProjectSection
8683
EndProject
8784
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pure.DI.Templates", "src\Pure.DI.Templates\Pure.DI.Templates.csproj", "{5A925B99-3FF8-4ED0-81C2-7F0D3AD52642}"
@@ -104,8 +101,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorServerApp", "samples\
104101
EndProject
105102
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssemblyApp", "samples\BlazorWebAssemblyApp\BlazorWebAssemblyApp.csproj", "{D1C043C4-ED8F-45C5-8077-EF10AA71B951}"
106103
EndProject
107-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherForecast", "samples\WeatherForecast\WeatherForecast.csproj", "{9A3E2271-3090-4BCE-BB48-6C0724CFBE44}"
108-
EndProject
109104
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalWebAPI", "samples\MinimalWebAPI\MinimalWebAPI.csproj", "{60F18CFA-957B-488F-8292-467D92C17267}"
110105
EndProject
111106
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingleRootAvaloniaApp", "samples\SingleRootAvaloniaApp\SingleRootAvaloniaApp.csproj", "{7FCFD4F6-AFB8-479C-A103-AEBC2FC282A8}"
@@ -123,6 +118,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "github", "github", "{CAA3DE
123118
.github\ISSUE_TEMPLATE\feature_request.md = .github\ISSUE_TEMPLATE\feature_request.md
124119
EndProjectSection
125120
EndProject
121+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GrpcClient", "samples\GrpcClient\GrpcClient.csproj", "{B0E4907A-2BB2-44B4-9BB6-70E1518BEE5C}"
122+
EndProject
123+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "samples\ConsoleApp\ConsoleApp.csproj", "{006A6849-86DC-43C7-8297-67249A807439}"
124+
EndProject
126125
Global
127126
GlobalSection(SolutionConfigurationPlatforms) = preSolution
128127
Debug|Any CPU = Debug|Any CPU
@@ -217,10 +216,6 @@ Global
217216
{D1C043C4-ED8F-45C5-8077-EF10AA71B951}.Debug|Any CPU.Build.0 = Debug|Any CPU
218217
{D1C043C4-ED8F-45C5-8077-EF10AA71B951}.Release|Any CPU.ActiveCfg = Release|Any CPU
219218
{D1C043C4-ED8F-45C5-8077-EF10AA71B951}.Release|Any CPU.Build.0 = Release|Any CPU
220-
{9A3E2271-3090-4BCE-BB48-6C0724CFBE44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
221-
{9A3E2271-3090-4BCE-BB48-6C0724CFBE44}.Debug|Any CPU.Build.0 = Debug|Any CPU
222-
{9A3E2271-3090-4BCE-BB48-6C0724CFBE44}.Release|Any CPU.ActiveCfg = Release|Any CPU
223-
{9A3E2271-3090-4BCE-BB48-6C0724CFBE44}.Release|Any CPU.Build.0 = Release|Any CPU
224219
{60F18CFA-957B-488F-8292-467D92C17267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
225220
{60F18CFA-957B-488F-8292-467D92C17267}.Debug|Any CPU.Build.0 = Debug|Any CPU
226221
{60F18CFA-957B-488F-8292-467D92C17267}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -241,6 +236,14 @@ Global
241236
{29F9986B-4B32-4C30-AECA-D68EAB4EA9CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
242237
{29F9986B-4B32-4C30-AECA-D68EAB4EA9CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
243238
{29F9986B-4B32-4C30-AECA-D68EAB4EA9CB}.Release|Any CPU.Build.0 = Release|Any CPU
239+
{B0E4907A-2BB2-44B4-9BB6-70E1518BEE5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
240+
{B0E4907A-2BB2-44B4-9BB6-70E1518BEE5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
241+
{B0E4907A-2BB2-44B4-9BB6-70E1518BEE5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
242+
{B0E4907A-2BB2-44B4-9BB6-70E1518BEE5C}.Release|Any CPU.Build.0 = Release|Any CPU
243+
{006A6849-86DC-43C7-8297-67249A807439}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
244+
{006A6849-86DC-43C7-8297-67249A807439}.Debug|Any CPU.Build.0 = Debug|Any CPU
245+
{006A6849-86DC-43C7-8297-67249A807439}.Release|Any CPU.ActiveCfg = Release|Any CPU
246+
{006A6849-86DC-43C7-8297-67249A807439}.Release|Any CPU.Build.0 = Release|Any CPU
244247
EndGlobalSection
245248
GlobalSection(NestedProjects) = preSolution
246249
{7C9E056B-CBA9-4548-9CDB-C5CE03C491B0} = {8163CDD7-7018-4301-A984-803C3807A6A6}
@@ -264,11 +267,12 @@ Global
264267
{E4274A56-868E-427E-87FE-E2D46749CAE6} = {FA80D231-C641-4A49-99C6-0C065D818B07}
265268
{6C95BC87-DA77-4CE7-8CAB-9BEC254CEF51} = {FA80D231-C641-4A49-99C6-0C065D818B07}
266269
{D1C043C4-ED8F-45C5-8077-EF10AA71B951} = {FA80D231-C641-4A49-99C6-0C065D818B07}
267-
{9A3E2271-3090-4BCE-BB48-6C0724CFBE44} = {FA80D231-C641-4A49-99C6-0C065D818B07}
268270
{60F18CFA-957B-488F-8292-467D92C17267} = {FA80D231-C641-4A49-99C6-0C065D818B07}
269271
{7FCFD4F6-AFB8-479C-A103-AEBC2FC282A8} = {FA80D231-C641-4A49-99C6-0C065D818B07}
270272
{136A2850-FDA0-4CDB-A798-21C4B4A01974} = {8163CDD7-7018-4301-A984-803C3807A6A6}
271273
{9D043E3D-878F-4D64-A689-7BE16A25842A} = {9DF1D09E-863F-4800-9E28-954440EE1601}
272274
{29F9986B-4B32-4C30-AECA-D68EAB4EA9CB} = {FA80D231-C641-4A49-99C6-0C065D818B07}
275+
{B0E4907A-2BB2-44B4-9BB6-70E1518BEE5C} = {FA80D231-C641-4A49-99C6-0C065D818B07}
276+
{006A6849-86DC-43C7-8297-67249A807439} = {FA80D231-C641-4A49-99C6-0C065D818B07}
273277
EndGlobalSection
274278
EndGlobal

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,75 +3471,75 @@ DI.Setup("Composition")
34713471
</blockquote></details>
34723472

34733473

3474-
<details><summary>Field Overrider</summary><blockquote>
3474+
<details><summary>Field UniqueTag</summary><blockquote>
34753475

3476-
Atomically generated smart tag with value "Overrider".
3476+
Atomically generated smart tag with value "UniqueTag".
34773477
It's used for:
34783478

3479-
class _Generator__DependencyGraphBuilder_ <-- _IGraphRewriter_(Overrider) -- _GraphOverrider_ as _PerBlock_
3479+
class _Generator__ApiInvocationProcessor_ <-- (UniqueTag) -- _IdGenerator_ as _PerResolve__BindingBuilder_ <-- _IIdGenerator_(UniqueTag) -- _IdGenerator_ as _PerResolve_
34803480
</blockquote></details>
34813481

34823482

3483-
<details><summary>Field UniqueTag</summary><blockquote>
3483+
<details><summary>Field GenericType</summary><blockquote>
34843484

3485-
Atomically generated smart tag with value "UniqueTag".
3485+
Atomically generated smart tag with value "GenericType".
34863486
It's used for:
34873487

3488-
class _Generator__ApiInvocationProcessor_ <-- (UniqueTag) -- _IdGenerator_ as _PerResolve__BindingBuilder_ <-- _IIdGenerator_(UniqueTag) -- _IdGenerator_ as _PerResolve_
3488+
class _Generator__TypeResolver_ <-- _IIdGenerator_(GenericType) -- _IdGenerator_ as _PerResolve_
34893489
</blockquote></details>
34903490

34913491

3492-
<details><summary>Field CompositionClass</summary><blockquote>
3492+
<details><summary>Field Overrider</summary><blockquote>
34933493

3494-
Atomically generated smart tag with value "CompositionClass".
3494+
Atomically generated smart tag with value "Overrider".
34953495
It's used for:
34963496

3497-
class _Generator__CodeBuilder_ <-- _IBuilder`2_(CompositionClass) -- _CompositionClassBuilder_ as _PerBlock_
3497+
class _Generator__DependencyGraphBuilder_ <-- _IGraphRewriter_(Overrider) -- _GraphOverrider_ as _PerBlock_
34983498
</blockquote></details>
34993499

35003500

3501-
<details><summary>Field Cleaner</summary><blockquote>
3501+
<details><summary>Field Override</summary><blockquote>
35023502

3503-
Atomically generated smart tag with value "Cleaner".
3503+
Atomically generated smart tag with value "Override".
35043504
It's used for:
35053505

3506-
class _Generator__DependencyGraphBuilder_ <-- _IGraphRewriter_(Cleaner) -- _GraphCleaner_ as _PerBlock_
3506+
class _Generator__OverrideIdProvider_ <-- _IIdGenerator_(Override) -- _IdGenerator_ as _PerResolve_
35073507
</blockquote></details>
35083508

35093509

3510-
<details><summary>Field UsingDeclarations</summary><blockquote>
3510+
<details><summary>Field Injection</summary><blockquote>
35113511

3512-
Atomically generated smart tag with value "UsingDeclarations".
3512+
Atomically generated smart tag with value "Injection".
35133513
It's used for:
35143514

3515-
class _Generator__CompositionClassBuilder_ <-- _IBuilder`2_(UsingDeclarations) -- _UsingDeclarationsBuilder_ as _PerBlock_
3515+
class _Generator__BuildTools_ <-- _IIdGenerator_(Injection) -- _IdGenerator_ as _PerResolve_
35163516
</blockquote></details>
35173517

35183518

3519-
<details><summary>Field GenericType</summary><blockquote>
3519+
<details><summary>Field CompositionClass</summary><blockquote>
35203520

3521-
Atomically generated smart tag with value "GenericType".
3521+
Atomically generated smart tag with value "CompositionClass".
35223522
It's used for:
35233523

3524-
class _Generator__TypeResolver_ <-- _IIdGenerator_(GenericType) -- _IdGenerator_ as _PerResolve_
3524+
class _Generator__CodeBuilder_ <-- _IBuilder`2_(CompositionClass) -- _CompositionClassBuilder_ as _PerBlock_
35253525
</blockquote></details>
35263526

35273527

3528-
<details><summary>Field Override</summary><blockquote>
3528+
<details><summary>Field UsingDeclarations</summary><blockquote>
35293529

3530-
Atomically generated smart tag with value "Override".
3530+
Atomically generated smart tag with value "UsingDeclarations".
35313531
It's used for:
35323532

3533-
class _Generator__OverrideIdProvider_ <-- _IIdGenerator_(Override) -- _IdGenerator_ as _PerResolve_
3533+
class _Generator__CompositionClassBuilder_ <-- _IBuilder`2_(UsingDeclarations) -- _UsingDeclarationsBuilder_ as _PerBlock_
35343534
</blockquote></details>
35353535

35363536

3537-
<details><summary>Field Injection</summary><blockquote>
3537+
<details><summary>Field Cleaner</summary><blockquote>
35383538

3539-
Atomically generated smart tag with value "Injection".
3539+
Atomically generated smart tag with value "Cleaner".
35403540
It's used for:
35413541

3542-
class _Generator__BuildTools_ <-- _IIdGenerator_(Injection) -- _IdGenerator_ as _PerResolve_
3542+
class _Generator__DependencyGraphBuilder_ <-- _IGraphRewriter_(Cleaner) -- _GraphCleaner_ as _PerBlock_
35433543
</blockquote></details>
35443544

35453545

@@ -5304,7 +5304,7 @@ Contextual AI needs to understand the situation it’s in. This means knowing de
53045304
| --------------- | ---- | ------ |
53055305
| [AI_CONTEXT_SMALL.md](AI_CONTEXT_SMALL.md) | 28KB | 7K |
53065306
| [AI_CONTEXT_MEDIUM.md](AI_CONTEXT_MEDIUM.md) | 122KB | 31K |
5307-
| [AI_CONTEXT_LARGE.md](AI_CONTEXT_LARGE.md) | 382KB | 98K |
5307+
| [AI_CONTEXT_LARGE.md](AI_CONTEXT_LARGE.md) | 375KB | 96K |
53085308
## How to contribute to Pure.DI
53095309

53105310
Thank you for your interest in contributing to the Pure.DI project! First of all, if you are going to make a big change or feature, please open a problem first. That way, we can coordinate and understand if the change you're going to work on fits with current priorities and if we can commit to reviewing and merging it within a reasonable timeframe. We don't want you to waste a lot of your valuable time on something that may not align with what we want for Pure.DI.

benchmarks/Pure.DI.Benchmarks/Pure.DI.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<PackageReference Include="SimpleInjector" Version="5.5.0"/>
2424
<PackageReference Include="Unity" Version="5.11.10"/>
2525
<PackageReference Include="DryIoc.dll" Version="5.4.3"/>
26-
<PackageReference Include="Autofac" Version="8.2.1" />
26+
<PackageReference Include="Autofac" Version="8.3.0" />
2727
<PackageReference Include="LightInject" Version="7.0.1"/>
2828
<PackageReference Include="Ninject" Version="3.3.6"/>
2929
<PackageReference Include="Castle.Windsor" Version="6.0.0"/>

readme/Avalonia.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ The definition of the composition is in [Composition.cs](/samples/AvaloniaApp/Co
1212
```csharp
1313
using Pure.DI;
1414
using static Pure.DI.Lifetime;
15+
using static Pure.DI.RootKinds;
1516

16-
internal partial class Composition
17+
namespace AvaloniaApp;
18+
19+
partial class Composition
1720
{
18-
void Setup() => DI.Setup()
19-
// Provides the composition root for the main window
20-
.Root<MainWindow>(nameof(MainWindow))
21-
// Provides the composition root for a Clock view model
22-
.Root<IClockViewModel>(nameof(ClockViewModel))
23-
24-
// View Models
21+
private void Setup() => DI.Setup()
22+
.Root<IAppViewModel>(nameof(App), kind: Virtual)
23+
.Root<IClockViewModel>(nameof(Clock), kind: Virtual)
24+
25+
.OrdinalAttribute<InitializableAttribute>()
26+
2527
.Bind().As(Singleton).To<ClockViewModel>()
28+
.Bind().To<ClockModel>()
29+
.Bind().As(Singleton).To<Ticks>()
2630

27-
// Models
28-
.Bind().To<Log<TT>>()
29-
.Bind().As(Singleton).To<Timer>()
30-
.Bind().As(PerBlock).To<SystemClock>()
31-
3231
// Infrastructure
33-
.Bind().To<Dispatcher>();
32+
.Bind().To<DebugLog<TT>>()
33+
.Bind().To<AvaloniaDispatcher>();
3434
}
3535
```
3636

@@ -55,10 +55,10 @@ A single instance of the _Composition_ class is defined as a static resource in
5555
<FluentTheme />
5656
</Application.Styles>
5757

58-
<!--Creates a shared resource of type `Composition` and with key _‘Composition’_,
59-
which will be further used as a data context in the views.-->
6058
<Application.Resources>
61-
<app:Composition x:Key="Composition" />
59+
<!--Creates a shared resource of type Composition and with key "Composition",
60+
which will be further used as a data context in the views.-->
61+
<app:Composition x:Key="Composition" />
6262
</Application.Resources>
6363

6464
</Application>
@@ -72,7 +72,7 @@ This markup fragment
7272
</Application.Resources>
7373
```
7474

75-
creates a shared resource of type `Composition` and with key _Composition_, which will be further used as a data context in the views.
75+
creates a shared resource of type `Composition` with key _"Composition"_, which will be further used as a data context in the views.
7676

7777
The associated application [App.axaml.cs](/samples/AvaloniaApp/App.axaml.cs) class is looking like:
7878

@@ -89,11 +89,11 @@ public class App : Application
8989
switch (ApplicationLifetime)
9090
{
9191
case IClassicDesktopStyleApplicationLifetime desktop:
92-
desktop.MainWindow = composition.MainWindow;
92+
desktop.MainWindow = new MainWindow();
9393
break;
9494

9595
case ISingleViewApplicationLifetime singleView:
96-
singleView.MainView = composition.MainWindow;
96+
singleView.MainView = new MainWindow();
9797
break;
9898
}
9999

@@ -114,27 +114,28 @@ Advantages over classical DI container libraries:
114114
- The code is simpler, more compact, and requires less maintenance effort.
115115
- The main window is created in a pure DI paradigm, and it can be easily supplied with all necessary dependencies via DI as regular types.
116116

117-
You can now use bindings to model views without even editing the views `.cs` code files. All previously defined composition roots are now accessible from [markup](/samples/AvaloniaApp/Views/MainWindow.xaml) without any effort, such as _ClockViewModel_:
117+
You can now use bindings and use the code-behind file-less approach. All previously defined composition roots are now available from [markup](/samples/AvaloniaApp/Views/MainWindow.xaml) without any effort, e.g. _Clock_:
118118

119119
```xml
120120
<Window xmlns="https://github.com/avaloniaui"
121121
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
122122
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
123123
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
124+
xmlns:app="clr-namespace:AvaloniaApp"
124125
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
125-
x:Class="AvaloniaApp.Views.MainWindow"
126+
x:Class="AvaloniaApp.MainWindow"
126127
DataContext="{StaticResource Composition}"
127-
xmlns:app="clr-namespace:AvaloniaApp"
128128
x:DataType="app:Composition"
129-
Title="{Binding ClockViewModel.Time}"
129+
Design.DataContext="{d:DesignInstance app:DesignTimeComposition}"
130+
Title="{Binding App.Title}"
130131
Icon="/Assets/avalonia-logo.ico"
131132
FontFamily="Consolas"
132133
FontWeight="Bold">
133134

134-
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" DataContext="{Binding ClockViewModel}">
135-
<TextBlock Text="{Binding Date}" FontSize="64" HorizontalAlignment="Center" />
136-
<TextBlock Text="{Binding Time}" FontSize="128" HorizontalAlignment="Center" />
137-
</StackPanel>
135+
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" DataContext="{Binding Clock}">
136+
<TextBlock Text="{Binding Date}" FontSize="64" HorizontalAlignment="Center" />
137+
<TextBlock Text="{Binding Time}" FontSize="128" HorizontalAlignment="Center" />
138+
</StackPanel>
138139

139140
</Window>
140141
```
@@ -145,6 +146,8 @@ To use bindings in views:
145146

146147
`DataContext="{StaticResource Composition}"`
147148

149+
and `Design.DataContext="{d:DesignInstance app:DesignTimeComposition}"` for the design time
150+
148151
- Specify the data type in the context:
149152

150153
`xmlns:app="clr-namespace:AvaloniaApp"`
@@ -153,7 +156,12 @@ To use bindings in views:
153156

154157
- Use the bindings as usual:
155158

156-
`Title="{Binding ClockViewModel.Time}"`
159+
```xml
160+
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" DataContext="{Binding Clock}">
161+
<TextBlock Text="{Binding Date}" FontSize="64" HorizontalAlignment="Center" />
162+
<TextBlock Text="{Binding Time}" FontSize="128" HorizontalAlignment="Center" />
163+
</StackPanel>
164+
```
157165

158166
Advantages over classical DI container libraries:
159167
- The code-behind `.cs` files for views are free of any logic.
@@ -165,15 +173,7 @@ The [project file](/samples/AvaloniaApp/AvaloniaApp.csproj) looks like this:
165173

166174
```xml
167175
<Project Sdk="Microsoft.NET.Sdk">
168-
169-
<PropertyGroup>
170-
<TargetFramework>net9.0</TargetFramework>
171-
<OutputType>WinExe</OutputType>
172-
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
173-
<ApplicationManifest>app.manifest</ApplicationManifest>
174-
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
175-
</PropertyGroup>
176-
176+
...
177177
<ItemGroup>
178178
<PackageReference Include="Pure.DI" Version="2.1.69">
179179
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)