-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f71207
commit 4b04b5c
Showing
82 changed files
with
3,091 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#### Wep API | ||
|
||
[![CSharp](https://img.shields.io/badge/C%23-code-blue.svg)](/samples/BlazorServerApp) | ||
|
||
This example demonstrates the creation of a [Blazor server](https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models#blazor-server) application in the pure DI paradigm using the _Pure.DI_ code generator. | ||
|
||
Composition setup file is [Composition.cs](/samples/BlazorServerApp/Composition.cs): | ||
|
||
```c# | ||
internal partial class Composition: ServiceProviderFactory<Composition> | ||
{ | ||
private static void Setup() => | ||
DI.Setup(nameof(Composition)) | ||
.DependsOn(Base) | ||
.Bind<IWeatherForecastService>() | ||
.As(Singleton) | ||
.To<WeatherForecastService>() | ||
.Root<IWeatherForecastService>() | ||
.Bind<ICounterService>() | ||
.To<CounterService>() | ||
.Root<ICounterService>() | ||
.Bind<IErrorModel>() | ||
.To<ErrorModel>() | ||
.Root<IErrorModel>(); | ||
} | ||
``` | ||
|
||
The composition class inherits from the `ServiceProviderFactory<T>` class, where T is the composition class itself. It depends on the `Base` setup. | ||
|
||
Te web application entry point is in the [Program.cs](/samples/BlazorServerApp/Program.cs) file: | ||
|
||
```c# | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Uses Composition as an alternative IServiceProviderFactory | ||
builder.Host.UseServiceProviderFactory(new Composition()); | ||
``` | ||
|
||
The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like this: | ||
|
||
```xml | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Pure.DI" Version="2.0.21"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Pure.DI.MS" Version="2.0.21" /> | ||
</ItemGroup> | ||
</Project> | ||
``` | ||
|
||
It contains 2 additional links to NuGet packages: | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#### Wep API | ||
|
||
[![CSharp](https://img.shields.io/badge/C%23-code-blue.svg)](/samples/BlazorServerApp) | ||
|
||
This example demonstrates the creation of a [Blazor server](https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models#blazor-server) application in the pure DI paradigm using the _Pure.DI_ code generator. | ||
|
||
Composition setup file is [Composition.cs](/samples/BlazorServerApp/Composition.cs): | ||
|
||
```c# | ||
internal partial class Composition: ServiceProviderFactory<Composition> | ||
{ | ||
private static void Setup() => | ||
DI.Setup(nameof(Composition)) | ||
.DependsOn(Base) | ||
.Bind<IWeatherForecastService>() | ||
.As(Singleton) | ||
.To<WeatherForecastService>() | ||
.Root<IWeatherForecastService>() | ||
.Bind<ICounterService>() | ||
.To<CounterService>() | ||
.Root<ICounterService>() | ||
.Bind<IErrorModel>() | ||
.To<ErrorModel>() | ||
.Root<IErrorModel>(); | ||
} | ||
``` | ||
|
||
The composition class inherits from the `ServiceProviderFactory<T>` class, where T is the composition class itself. It depends on the `Base` setup. | ||
|
||
Te web application entry point is in the [Program.cs](/samples/BlazorServerApp/Program.cs) file: | ||
|
||
```c# | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Uses Composition as an alternative IServiceProviderFactory | ||
builder.Host.UseServiceProviderFactory(new Composition()); | ||
``` | ||
|
||
The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like this: | ||
|
||
```xml | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Pure.DI" Version="$(version)"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Pure.DI.MS" Version="$(version)" /> | ||
</ItemGroup> | ||
</Project> | ||
``` | ||
|
||
It contains 2 additional links to NuGet packages: | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#### Wep API | ||
|
||
[![CSharp](https://img.shields.io/badge/C%23-code-blue.svg)](/samples/BlazorServerApp) | ||
|
||
This example demonstrates the creation of a [Blazor WebAssembly](https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models#blazor-webassembly) application in the pure DI paradigm using the _Pure.DI_ code generator. | ||
|
||
Composition setup file is [Composition.cs](/samples/BlazorWebAssemblyApp/Composition.cs): | ||
|
||
```c# | ||
internal partial class Composition: ServiceProviderFactory<Composition> | ||
{ | ||
private static void Setup() => | ||
DI.Setup(nameof(Composition)) | ||
.DependsOn(Base) | ||
.Bind<IWeatherForecastService>() | ||
.As(Singleton) | ||
.To<WeatherForecastService>() | ||
.Root<IWeatherForecastService>() | ||
.Bind<ICounterService>() | ||
.To<CounterService>() | ||
.Root<ICounterService>(); | ||
} | ||
``` | ||
|
||
The composition class inherits from the `ServiceProviderFactory<T>` class, where T is the composition class itself. It depends on the `Base` setup. | ||
|
||
Te web application entry point is in the [Program.cs](/samples/BlazorWebAssemblyApp/Program.cs) file: | ||
|
||
```c# | ||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
|
||
// Uses Composition as an alternative IServiceProviderFactory | ||
builder.ConfigureContainer(new Composition()); | ||
``` | ||
|
||
The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) looks like this: | ||
|
||
```xml | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Pure.DI" Version="2.0.21"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Pure.DI.MS" Version="2.0.21" /> | ||
</ItemGroup> | ||
</Project> | ||
``` | ||
|
||
It contains 2 additional links to NuGet packages: | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#### Wep API | ||
|
||
[![CSharp](https://img.shields.io/badge/C%23-code-blue.svg)](/samples/BlazorServerApp) | ||
|
||
This example demonstrates the creation of a [Blazor WebAssembly](https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models#blazor-webassembly) application in the pure DI paradigm using the _Pure.DI_ code generator. | ||
|
||
Composition setup file is [Composition.cs](/samples/BlazorWebAssemblyApp/Composition.cs): | ||
|
||
```c# | ||
internal partial class Composition: ServiceProviderFactory<Composition> | ||
{ | ||
private static void Setup() => | ||
DI.Setup(nameof(Composition)) | ||
.DependsOn(Base) | ||
.Bind<IWeatherForecastService>() | ||
.As(Singleton) | ||
.To<WeatherForecastService>() | ||
.Root<IWeatherForecastService>() | ||
.Bind<ICounterService>() | ||
.To<CounterService>() | ||
.Root<ICounterService>(); | ||
} | ||
``` | ||
|
||
The composition class inherits from the `ServiceProviderFactory<T>` class, where T is the composition class itself. It depends on the `Base` setup. | ||
|
||
Te web application entry point is in the [Program.cs](/samples/BlazorWebAssemblyApp/Program.cs) file: | ||
|
||
```c# | ||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
|
||
// Uses Composition as an alternative IServiceProviderFactory | ||
builder.ConfigureContainer(new Composition()); | ||
``` | ||
|
||
The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) looks like this: | ||
|
||
```xml | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Pure.DI" Version="$(version)"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Pure.DI.MS" Version="$(version)" /> | ||
</ItemGroup> | ||
</Project> | ||
``` | ||
|
||
It contains 2 additional links to NuGet packages: | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) | ||
|
||
[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Router AppAssembly="@typeof(App).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1"/> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\WeatherForecast\WeatherForecast.csproj"/> | ||
<ProjectReference Include="..\..\src\Pure.DI.Core\Pure.DI.Core.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/> | ||
<ProjectReference Include="..\..\src\Pure.DI\Pure.DI.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/> | ||
<Compile Include="..\..\src\Pure.DI.MS\ServiceCollectionFactory.g.cs"> | ||
<Link>ServiceCollectionFactory.g.cs</Link> | ||
</Compile> | ||
<Compile Include="..\..\src\Pure.DI.MS\ServiceProviderFactory.g.cs"> | ||
<Link>ServiceProviderFactory.g.cs</Link> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ReSharper disable UnusedMember.Local | ||
|
||
namespace BlazorServerApp; | ||
|
||
using Models; | ||
using Pure.DI; | ||
using Pure.DI.MS; | ||
using WeatherForecast; | ||
using static Pure.DI.Lifetime; | ||
|
||
internal partial class Composition: ServiceProviderFactory<Composition> | ||
{ | ||
private static void Setup() => | ||
DI.Setup(nameof(Composition)) | ||
.DependsOn(Base) | ||
.Bind<IWeatherForecastService>() | ||
.As(Singleton) | ||
.To<WeatherForecastService>() | ||
.Root<IWeatherForecastService>() | ||
.Bind<ICounterService>() | ||
.To<CounterService>() | ||
.Root<ICounterService>() | ||
.Bind<IErrorModel>() | ||
.To<ErrorModel>() | ||
.Root<IErrorModel>(); | ||
} |
Oops, something went wrong.