Skip to content

Commit 36b4384

Browse files
committed
v2.4.0 Update to .NET 9, Add roslynator
1 parent 39bb57b commit 36b4384

Some content is hidden

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

48 files changed

+152
-247
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
***
44
## Стек технологий:
55
* Avalonia
6-
* .NET 8, C#
6+
* .NET 9, C#
77
* EF Core
88
* SqlLite
99
***

src/SudInfo.Avalonia/App.axaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public async override void OnFrameworkInitializationCompleted()
3333

3434
if (appSetting.Theme == "Acrylic")
3535
{
36-
mainWindow.TransparencyLevelHint = new List<WindowTransparencyLevel>() {
36+
mainWindow.TransparencyLevelHint = [
3737
WindowTransparencyLevel.AcrylicBlur
38-
};
38+
];
3939
mainWindow.Background = null;
4040
}
4141

@@ -67,7 +67,6 @@ public async override void OnFrameworkInitializationCompleted()
6767

6868
mainWindow.Show();
6969
MainWindow = mainWindow;
70-
7170
}
7271

7372
#endregion

src/SudInfo.Avalonia/Extensions/ServiceCollectionExtension.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
internal static class ServiceCollectionExtension
44
{
55
public static readonly IServiceProvider ServiceProvider = new ServiceCollection()
6+
67
#region Page view models
78
.AddScoped<ComputersPageViewModel>()
89
.AddScoped<PrintersPageViewModel>()
@@ -19,6 +20,7 @@ internal static class ServiceCollectionExtension
1920
.AddScoped<CartridgesPageViewModel>()
2021
.AddScoped<PhonesPageViewModel>()
2122
#endregion
23+
2224
#region Window view models
2325
.AddScoped<AppWindowViewModel>()
2426
.AddScoped<CartridgeWindowViewModel>()
@@ -35,8 +37,8 @@ internal static class ServiceCollectionExtension
3537
.AddScoped<PrinterWindowViewModel>()
3638
.AddScoped<PhoneWindowViewModel>()
3739
#endregion
40+
3841
#region Services
39-
.AddTransient<ExcelService>()
4042
.AddTransient<PrinterService>()
4143
.AddTransient<RutokenService>()
4244
.AddTransient<PeripheryService>()
@@ -52,7 +54,7 @@ internal static class ServiceCollectionExtension
5254
.AddSingleton<NavigationService>()
5355
.AddTransient<ComputerService>()
5456
.AddTransient<PhoneService>()
55-
#endregion
5657
.AddTransient<SudInfoDatabaseContext>()
5758
.BuildServiceProvider();
59+
#endregion
5860
}
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
namespace SudInfo.Avalonia.Models;
22

3-
public class Result<T> : Result
3+
public class Result<T>(T? obj, bool success = false, string message = "") : Result(success, message)
44
{
5-
public Result(T? obj, bool success = false, string message = "") : base(success, message)
6-
{
7-
Object = obj;
8-
}
9-
10-
public T? Object { get; set; }
5+
public T? Object { get; set; } = obj;
116
}
12-
public class Result
13-
{
14-
public Result(bool success = false, string message = "")
15-
{
16-
Success = success;
17-
Message = message;
18-
}
197

20-
public bool Success { get; set; }
8+
public class Result(bool success = false, string message = "")
9+
{
10+
public bool Success { get; set; } = success;
2111

22-
public string Message { get; set; } = string.Empty;
12+
public string Message { get; set; } = message;
2313
}

src/SudInfo.Avalonia/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace SudInfo.Avalonia;
22

3-
internal class Program
3+
internal static class Program
44
{
55
[STAThread]
66
public static void Main(string[] args) => BuildAvaloniaApp()

src/SudInfo.Avalonia/Services/AppService.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
namespace SudInfo.Avalonia.Services;
22

3-
public class AppService : BaseService<AppEntity>
3+
public class AppService(SudInfoDatabaseContext context) : BaseService<AppEntity>(context)
44
{
55
#region Ctors
66

7-
public AppService(SudInfoDatabaseContext context) : base(context)
8-
{
9-
}
10-
117
#endregion
128

139
#region Get Methods
1410

1511
public async Task<IReadOnlyCollection<AppEntity>> Get()
1612
{
17-
var apps = await context.Apps.AsNoTracking()
13+
return await context.Apps.AsNoTracking()
1814
.Include(x => x.Computers)
1915
.ThenInclude(x => x.User)
2016
.ToListAsync();
21-
return apps;
2217
}
2318

2419
public async Task<Result<AppEntity>> Get(int id)
@@ -71,7 +66,7 @@ public async Task<Result> Update(AppEntity entity)
7166
}
7267
else
7368
{
74-
app.Computers = new List<Computer>();
69+
app.Computers = [];
7570
foreach (var computer in entity.Computers)
7671
{
7772
app.Computers.Add(await context.Computers.FindAsync(computer.Id));
@@ -92,7 +87,7 @@ public override async Task<Result> Add(AppEntity entity)
9287
try
9388
{
9489
var computers = entity.Computers;
95-
entity.Computers = new List<Computer>();
90+
entity.Computers = [];
9691
foreach (var computer in computers)
9792
{
9893
entity.Computers.Add(await context.Computers.FindAsync(computer.Id));

src/SudInfo.Avalonia/Services/BaseService.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
namespace SudInfo.Avalonia.Services;
22

3-
public class BaseService<T> where T : class
3+
public class BaseService<T>(SudInfoDatabaseContext context) where T : class
44
{
55
#region Private variables
66

7-
protected readonly SudInfoDatabaseContext context;
7+
protected readonly SudInfoDatabaseContext context = context;
88

99
#endregion
10-
1110
#region Ctors
1211

13-
public BaseService(SudInfoDatabaseContext context)
14-
{
15-
this.context = context;
16-
}
17-
1812
#endregion
1913

2014
#region Methods

src/SudInfo.Avalonia/Services/CartridgeService.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
namespace SudInfo.Avalonia.Services;
44

5-
public class CartridgeService : BaseService<Cartridge>
5+
public class CartridgeService(SudInfoDatabaseContext context) : BaseService<Cartridge>(context)
66
{
77
#region Ctors
88

9-
public CartridgeService(SudInfoDatabaseContext context) : base(context)
10-
{
11-
}
12-
139
#endregion
1410

1511
#region Get Methods
@@ -29,9 +25,8 @@ public async Task<Result<Cartridge>> Get(int id)
2925

3026
public async Task<IReadOnlyCollection<Cartridge>> Get()
3127
{
32-
var cartridges = await context.Cartridges.AsNoTracking()
28+
return await context.Cartridges.AsNoTracking()
3329
.ToListAsync();
34-
return cartridges;
3530
}
3631

3732
#endregion

src/SudInfo.Avalonia/Services/ComputerService.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
namespace SudInfo.Avalonia.Services;
22

3-
public class ComputerService : BaseService<Computer>
3+
public class ComputerService(SudInfoDatabaseContext context) : BaseService<Computer>(context)
44
{
55
#region Ctors
66

7-
public ComputerService(SudInfoDatabaseContext context) : base(context)
8-
{
9-
}
10-
117
#endregion
128

139
#region Get Methods
@@ -30,10 +26,9 @@ public async Task<Result<Computer>> Get(int id)
3026

3127
public async Task<IReadOnlyCollection<Computer>> Get()
3228
{
33-
var computers = await context.Computers.AsNoTracking()
29+
return await context.Computers.AsNoTracking()
3430
.Include(x => x.User)
3531
.ToListAsync();
36-
return computers;
3732
}
3833

3934
#endregion

src/SudInfo.Avalonia/Services/ContactService.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
namespace SudInfo.Avalonia.Services;
22

3-
public class ContactService : BaseService<Contact>
3+
public class ContactService(SudInfoDatabaseContext context) : BaseService<Contact>(context)
44
{
55
#region Ctors
66

7-
public ContactService(SudInfoDatabaseContext context) : base(context)
8-
{
9-
}
10-
117
#endregion
128

139
#region Get Methods
1410

1511
public async Task<IReadOnlyCollection<Contact>> Get()
1612
{
17-
var contacts = await context.Contacts.AsNoTracking()
13+
return await context.Contacts.AsNoTracking()
1814
.ToListAsync();
19-
return contacts;
2015
}
2116

2217
public async Task<Result<Contact>> Get(int id)

0 commit comments

Comments
 (0)