Skip to content

Commit 6fa0938

Browse files
committed
feature: csharp 12
1 parent fbe6fa3 commit 6fa0938

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

src/Umbraco.Community.DataProtection/Persistence/DataProtectionMigration.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,18 @@
1010

1111
namespace Umbraco.Community.DataProtection.Persistence;
1212

13-
public class DataProtectionMigration : PackageMigrationBase
14-
{
15-
public DataProtectionMigration(
16-
IPackagingService packagingService,
17-
IMediaService mediaService,
18-
MediaFileManager mediaFileManager,
19-
MediaUrlGeneratorCollection mediaUrlGenerators,
20-
IShortStringHelper shortStringHelper,
21-
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
22-
IMigrationContext context,
23-
IOptions<PackageMigrationSettings> packageMigrationsSettings) : base(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider,
13+
public class DataProtectionMigration(
14+
IPackagingService packagingService,
15+
IMediaService mediaService,
16+
MediaFileManager mediaFileManager,
17+
MediaUrlGeneratorCollection mediaUrlGenerators,
18+
IShortStringHelper shortStringHelper,
19+
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
20+
IMigrationContext context,
21+
IOptions<PackageMigrationSettings> packageMigrationsSettings)
22+
: PackageMigrationBase(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider,
2423
context, packageMigrationsSettings)
25-
{
26-
}
27-
24+
{
2825
protected override void Migrate()
2926
{
3027
if (!TableExists(Constants.Tables.DataProtectionKeys))

src/Umbraco.Community.DataProtection/Persistence/MigrationPlan.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
namespace Umbraco.Community.DataProtection.Persistence;
44

5-
public class MigrationPlan : PackageMigrationPlan
5+
public class MigrationPlan() : PackageMigrationPlan(Constants.PackageId)
66
{
7-
public MigrationPlan() : base(Constants.PackageId)
8-
{
9-
}
10-
117
protected override void DefinePlan()
128
{
139
To<DataProtectionMigration>(nameof(DataProtectionMigration));

src/Umbraco.Community.DataProtection/Persistence/UmbracoXmlRepository.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,13 @@
77

88
namespace Umbraco.Community.DataProtection.Persistence;
99

10-
public class UmbracoXmlRepository : IXmlRepository
10+
public class UmbracoXmlRepository(IScopeProvider scopeProvider, ILogger<UmbracoXmlRepository> logger) : IXmlRepository
1111
{
12-
private readonly ILogger<UmbracoXmlRepository> _logger;
13-
private readonly IScopeProvider _scopeProvider;
14-
15-
public UmbracoXmlRepository(IScopeProvider scopeProvider, ILogger<UmbracoXmlRepository> logger)
16-
{
17-
_scopeProvider = scopeProvider;
18-
_logger = logger;
19-
}
20-
2112
public IReadOnlyCollection<XElement> GetAllElements()
2213
{
2314
try
2415
{
25-
using var scope = _scopeProvider.CreateScope();
16+
using var scope = scopeProvider.CreateScope();
2617
var sql = scope.SqlContext.Sql().SelectAll().From<DataProtectionKey>();
2718
var results = scope.Database.Fetch<DataProtectionKey>(sql);
2819
var output = results.Select(x => XElement.Parse(x.Xml!)).WhereNotNull().ToList().AsReadOnly();
@@ -31,7 +22,7 @@ public IReadOnlyCollection<XElement> GetAllElements()
3122
}
3223
catch (Exception ex)
3324
{
34-
_logger.LogError(ex, "Error getting all elements");
25+
logger.LogError(ex, "Error getting all elements");
3526
return Array.Empty<XElement>();
3627
}
3728
}
@@ -40,7 +31,7 @@ public void StoreElement(XElement element, string friendlyName)
4031
{
4132
try
4233
{
43-
using var scope = _scopeProvider.CreateScope(autoComplete: false);
34+
using var scope = scopeProvider.CreateScope(autoComplete: false);
4435
var key = new DataProtectionKey
4536
{
4637
FriendlyName = friendlyName,
@@ -51,7 +42,7 @@ public void StoreElement(XElement element, string friendlyName)
5142
}
5243
catch (Exception ex)
5344
{
54-
_logger.LogError(ex, "Error storing element");
45+
logger.LogError(ex, "Error storing element");
5546
}
5647
}
5748
}

src/Umbraco.Community.DataProtection/Umbraco.Community.DataProtection.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
4-
<LangVersion>10</LangVersion>
4+
<LangVersion>12</LangVersion>
55
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>

0 commit comments

Comments
 (0)