Skip to content

Commit

Permalink
working example for #567
Browse files Browse the repository at this point in the history
  • Loading branch information
dadhi committed Apr 12, 2023
1 parent 12a470b commit 13607cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
7 changes: 7 additions & 0 deletions samples/BlazorServerSide/BlazorServerSide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />

<PackageReference Include="DryIoc.Microsoft.DependencyInjection" Version="6.1.1" />
<!-- <ProjectReference Include="..\..\src\DryIoc.Microsoft.DependencyInjection\DryIoc.Microsoft.DependencyInjection.csproj" /> -->
</ItemGroup>

</Project>
28 changes: 27 additions & 1 deletion samples/BlazorServerSide/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using BlazorServerSide.Data;
using Serilog;
using DryIoc;
using DryIoc.Microsoft.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

var container = new Container(
// this is causing the #567 error
// Rules.MicrosoftDependencyInjectionRules.With(propertiesAndFields: PropertiesAndFields.Auto)
);

// Here it goes the integration with the existing DryIoc container
var diFactory = new DryIocServiceProviderFactory(container, RegistrySharing.Share);
builder.Host.UseServiceProviderFactory(diFactory);


// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddServerSideBlazor(options =>
{
options.DetailedErrors = true;
});

// Configure Serilog Logger
var logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.ReadFrom.Configuration(builder.Configuration)
.Enrich.FromLogContext()
.WriteTo.File("Errors/Log_.txt", rollingInterval: RollingInterval.Day)
.CreateLogger();
builder.Host.UseSerilog(logger);

builder.Services.AddSingleton<WeatherForecastService>();

var app = builder.Build();
Expand Down

0 comments on commit 13607cf

Please sign in to comment.