Skip to content

Commit 42e0ac0

Browse files
author
alex
committed
update to .net 6
1 parent 3a2730e commit 42e0ac0

File tree

97 files changed

+1194
-1635
lines changed

Some content is hidden

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

97 files changed

+1194
-1635
lines changed

EFCore/ASP.NetCore/Blazor.ServerSide/Blazor.ServerSide.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>net5.0</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
45
</PropertyGroup>
56
<ItemGroup>
67
<PackageReference Include="DevExpress.Blazor" Version="21.2.4" />
Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,56 @@
1-
using Microsoft.AspNetCore.Hosting;
2-
using Microsoft.Extensions.Hosting;
1+
using Blazor.ServerSide.Helpers;
2+
using BusinessObjectsLibrary.BusinessObjects;
3+
using DevExpress.ExpressApp.Security;
4+
using DevExpress.ExpressApp;
5+
using DevExpress.Persistent.BaseImpl.EF.PermissionPolicy;
6+
using Microsoft.AspNetCore.Authentication.Cookies;
7+
using Microsoft.EntityFrameworkCore;
38

4-
namespace Blazor.ServerSide {
5-
public class Program {
6-
public static void Main(string[] args) {
7-
CreateHostBuilder(args).Build().Run();
8-
}
9+
var builder = WebApplication.CreateBuilder(args);
910

10-
public static IHostBuilder CreateHostBuilder(string[] args) =>
11-
Host.CreateDefaultBuilder(args)
12-
.ConfigureWebHostDefaults(webBuilder => {
13-
webBuilder.UseStaticWebAssets();
14-
webBuilder.UseStartup<Startup>();
15-
});
16-
}
11+
builder.Services.AddRazorPages();
12+
builder.Services.AddServerSideBlazor();
13+
builder.Services.AddDevExpressBlazor();
14+
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
15+
builder.Services.AddHttpContextAccessor();
16+
builder.Services.AddSession();
17+
18+
builder.Services.AddDbContextFactory<ApplicationDbContext>((serviceProvider, options) => {
19+
string connectionString = builder.Configuration.GetConnectionString("ConnectionString");
20+
options.UseSqlServer(connectionString);
21+
options.UseLazyLoadingProxies();
22+
options.UseSecurity(serviceProvider.GetRequiredService<SecurityStrategyComplex>(), XafTypesInfo.Instance);
23+
}, ServiceLifetime.Scoped);
24+
builder.Services.AddScoped<SecurityProvider>();
25+
builder.Services.AddScoped((serviceProvider) => {
26+
AuthenticationMixed authentication = new AuthenticationMixed();
27+
authentication.LogonParametersType = typeof(AuthenticationStandardLogonParameters);
28+
authentication.AddAuthenticationStandardProvider(typeof(PermissionPolicyUser));
29+
authentication.AddIdentityAuthenticationProvider(typeof(PermissionPolicyUser));
30+
SecurityStrategyComplex security = new SecurityStrategyComplex(typeof(PermissionPolicyUser), typeof(PermissionPolicyRole), authentication);
31+
return security;
32+
});
33+
34+
var app = builder.Build();
35+
36+
if (app.Environment.IsDevelopment()) {
37+
app.UseDeveloperExceptionPage();
1738
}
39+
else {
40+
app.UseExceptionHandler("/Error");
41+
app.UseHsts();
42+
}
43+
44+
app.UseSession();
45+
app.UseHttpsRedirection();
46+
app.UseStaticFiles();
47+
app.UseAuthentication();
48+
app.UseDefaultFiles();
49+
app.UseRouting();
50+
app.UseEndpoints(endpoints => {
51+
endpoints.MapBlazorHub();
52+
endpoints.MapFallbackToPage("/_Host");
53+
});
54+
app.UseDemoData<ApplicationDbContext>((builder, _) =>
55+
builder.UseSqlServer(app.Configuration.GetConnectionString("ConnectionString")));
56+
app.Run();

EFCore/ASP.NetCore/Blazor.ServerSide/Startup.DevExpress.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

EFCore/ASP.NetCore/Blazor.ServerSide/Startup.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

EFCore/ASP.NetCore/DevExtreme.OData/Controllers/AccountController.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using System;
2-
using Microsoft.AspNetCore.Authentication;
1+
using Microsoft.AspNetCore.Authentication;
32
using Microsoft.AspNetCore.Authorization;
4-
using Microsoft.AspNetCore.Http;
53
using Microsoft.AspNetCore.Mvc;
64
using Microsoft.AspNetCore.OData.Routing.Controllers;
75

EFCore/ASP.NetCore/DevExtreme.OData/Controllers/ActionsController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections;
3-
using System.Collections.Generic;
4-
using System.Linq;
1+
using System.Collections;
52
using Microsoft.AspNetCore.Mvc;
63
using Microsoft.AspNetCore.OData.Formatter;
74
using Microsoft.AspNetCore.OData.Routing.Controllers;

EFCore/ASP.NetCore/DevExtreme.OData/Controllers/DepartmentsController.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Linq;
3-
using Microsoft.AspNetCore.Mvc;
1+
using Microsoft.AspNetCore.Mvc;
42
using Microsoft.AspNetCore.OData.Query;
53
using Microsoft.AspNetCore.OData.Routing.Controllers;
64
using DevExpress.ExpressApp;
Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,59 @@
1-
using System;
2-
using System.Linq;
3-
using System.Text.Json;
1+
using System.Text.Json;
42
using Microsoft.AspNetCore.Mvc;
53
using Microsoft.AspNetCore.OData.Routing.Controllers;
64
using Microsoft.EntityFrameworkCore;
75
using Microsoft.AspNetCore.OData.Query;
86
using DevExpress.ExpressApp;
97
using BusinessObjectsLibrary.BusinessObjects;
10-
using DevExtreme.OData;
118

12-
//namespace DevExtreme.OData.Controllers {
13-
public class EmployeesController : ODataController, IDisposable {
14-
SecurityProvider securityProvider;
15-
IObjectSpace objectSpace;
16-
public EmployeesController(SecurityProvider securityProvider) {
17-
this.securityProvider = securityProvider;
18-
objectSpace = securityProvider.ObjectSpaceProvider.CreateObjectSpace();
19-
}
20-
[HttpGet]
21-
[EnableQuery]
22-
public ActionResult Get() {
23-
// The EFCore way:
24-
// var dbContext = ((EFCoreObjectSpace)objectSpace).DbContext;
25-
//
26-
// The XAF way:
27-
IQueryable<Employee> employees = objectSpace.GetObjectsQuery<Employee>().Include(e => e.Department);
28-
return Ok(employees);
29-
}
30-
[HttpDelete]
31-
public ActionResult Delete(int key) {
32-
Employee existing = objectSpace.GetObjectByKey<Employee>(key);
33-
if(existing != null) {
34-
objectSpace.Delete(existing);
35-
objectSpace.CommitChanges();
36-
return NoContent();
9+
namespace DevExtreme.OData.Controllers {
10+
public class EmployeesController : ODataController, IDisposable {
11+
SecurityProvider securityProvider;
12+
IObjectSpace objectSpace;
13+
public EmployeesController(SecurityProvider securityProvider) {
14+
this.securityProvider = securityProvider;
15+
objectSpace = securityProvider.ObjectSpaceProvider.CreateObjectSpace();
3716
}
38-
return NotFound();
39-
}
40-
[HttpPatch]
41-
public ActionResult Patch(int key, [FromBody] JsonElement serializedProperties) {
42-
Employee employee = objectSpace.FirstOrDefault<Employee>(e => e.ID == key);
43-
if(employee != null) {
44-
JsonParser.ParseJson<Employee>(serializedProperties, employee, objectSpace);
17+
[HttpGet]
18+
[EnableQuery]
19+
public ActionResult Get() {
20+
// The EFCore way:
21+
// var dbContext = ((EFCoreObjectSpace)objectSpace).DbContext;
22+
//
23+
// The XAF way:
24+
IQueryable<Employee> employees = objectSpace.GetObjectsQuery<Employee>().Include(e => e.Department);
25+
return Ok(employees);
26+
}
27+
[HttpDelete]
28+
public ActionResult Delete(int key) {
29+
Employee existing = objectSpace.GetObjectByKey<Employee>(key);
30+
if(existing != null) {
31+
objectSpace.Delete(existing);
32+
objectSpace.CommitChanges();
33+
return NoContent();
34+
}
35+
return NotFound();
36+
}
37+
[HttpPatch]
38+
public ActionResult Patch(int key, [FromBody] JsonElement serializedProperties) {
39+
Employee employee = objectSpace.FirstOrDefault<Employee>(e => e.ID == key);
40+
if(employee != null) {
41+
JsonParser.ParseJson<Employee>(serializedProperties, employee, objectSpace);
42+
objectSpace.CommitChanges();
43+
return Ok(employee);
44+
}
45+
return NotFound();
46+
}
47+
[HttpPost]
48+
public ActionResult Post([FromBody] JsonElement serializedProperties) {
49+
Employee newEmployee = objectSpace.CreateObject<Employee>();
50+
JsonParser.ParseJson<Employee>(serializedProperties, newEmployee, objectSpace);
4551
objectSpace.CommitChanges();
46-
return Ok(employee);
52+
return Ok(newEmployee);
53+
}
54+
public void Dispose() {
55+
objectSpace?.Dispose();
56+
securityProvider?.Dispose();
4757
}
48-
return NotFound();
49-
}
50-
[HttpPost]
51-
public ActionResult Post([FromBody] JsonElement serializedProperties) {
52-
Employee newEmployee = objectSpace.CreateObject<Employee>();
53-
JsonParser.ParseJson<Employee>(serializedProperties, newEmployee, objectSpace);
54-
objectSpace.CommitChanges();
55-
return Ok(newEmployee);
56-
}
57-
public void Dispose() {
58-
objectSpace?.Dispose();
59-
securityProvider?.Dispose();
6058
}
6159
}
62-
//}

EFCore/ASP.NetCore/DevExtreme.OData/DevExtreme.OData.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>net5.0</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
45
</PropertyGroup>
56
<ItemGroup>
67
<PackageReference Include="microsoft.aspnetcore.odata" Version="8.0.1" />

EFCore/ASP.NetCore/DevExtreme.OData/Helpers/ApplicationBuilderExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Microsoft.AspNetCore.Builder;
2-
using Microsoft.EntityFrameworkCore;
1+
using Microsoft.EntityFrameworkCore;
32
using DevExpress.ExpressApp.EFCore;
43
using DatabaseUpdater;
54

0 commit comments

Comments
 (0)