From 615d76f5d275cdda1ac80c5b8e49b6bbafdf7e09 Mon Sep 17 00:00:00 2001 From: Nikolay Pianikov Date: Sun, 22 Dec 2024 15:04:03 +0300 Subject: [PATCH] Avalonia example --- .../AvaloniaSimpleApp.csproj | 13 +++++----- samples/AvaloniaSimpleApp/BusinessService.cs | 12 ++++++--- samples/AvaloniaSimpleApp/IMainViewModel.cs | 2 +- samples/AvaloniaSimpleApp/MainViewModel.cs | 12 ++++++--- samples/AvaloniaSimpleApp/MainWindow.axaml | 2 +- samples/AvaloniaSimpleApp/Repository.cs | 2 +- samples/AvaloniaSimpleApp/app.manifest | 26 +++++++++---------- 7 files changed, 41 insertions(+), 28 deletions(-) diff --git a/samples/AvaloniaSimpleApp/AvaloniaSimpleApp.csproj b/samples/AvaloniaSimpleApp/AvaloniaSimpleApp.csproj index a0551c3eb..e406a484c 100644 --- a/samples/AvaloniaSimpleApp/AvaloniaSimpleApp.csproj +++ b/samples/AvaloniaSimpleApp/AvaloniaSimpleApp.csproj @@ -1,7 +1,8 @@  WinExe - net8.0 + net9.0 + 11 enable true app.manifest @@ -11,11 +12,11 @@ - - - - + + + + - + diff --git a/samples/AvaloniaSimpleApp/BusinessService.cs b/samples/AvaloniaSimpleApp/BusinessService.cs index 4dd3db29f..b80d7e959 100644 --- a/samples/AvaloniaSimpleApp/BusinessService.cs +++ b/samples/AvaloniaSimpleApp/BusinessService.cs @@ -1,11 +1,17 @@ namespace AvaloniaSimpleApp; -public class BusinessService(IRepository repository) - : IBusinessService +public class BusinessService : IBusinessService { + private readonly IRepository _repository; + + public BusinessService(IRepository repository) + { + _repository = repository; + } + public string CreateGreetings() { - repository.RegisterSomething(); + _repository.RegisterSomething(); return "Example of Dependency Injection implementation using Pure.DI"; } } \ No newline at end of file diff --git a/samples/AvaloniaSimpleApp/IMainViewModel.cs b/samples/AvaloniaSimpleApp/IMainViewModel.cs index 5f7c8d431..a3555a29c 100644 --- a/samples/AvaloniaSimpleApp/IMainViewModel.cs +++ b/samples/AvaloniaSimpleApp/IMainViewModel.cs @@ -3,6 +3,6 @@ public interface IMainViewModel { string Title { get; } - + string Greetings { get; } } \ No newline at end of file diff --git a/samples/AvaloniaSimpleApp/MainViewModel.cs b/samples/AvaloniaSimpleApp/MainViewModel.cs index 309e397af..c1ed4c30d 100644 --- a/samples/AvaloniaSimpleApp/MainViewModel.cs +++ b/samples/AvaloniaSimpleApp/MainViewModel.cs @@ -1,9 +1,15 @@ namespace AvaloniaSimpleApp; -public class MainViewModel(IBusinessService businessService) - : IMainViewModel +public class MainViewModel : IMainViewModel { + private readonly IBusinessService _businessService; + + public MainViewModel(IBusinessService businessService) + { + _businessService = businessService; + } + public string Title => "Avalonia application"; - public string Greetings => businessService.CreateGreetings(); + public string Greetings => _businessService.CreateGreetings(); } \ No newline at end of file diff --git a/samples/AvaloniaSimpleApp/MainWindow.axaml b/samples/AvaloniaSimpleApp/MainWindow.axaml index 4b7423dba..7602d74ca 100644 --- a/samples/AvaloniaSimpleApp/MainWindow.axaml +++ b/samples/AvaloniaSimpleApp/MainWindow.axaml @@ -8,4 +8,4 @@ xmlns:app="clr-namespace:AvaloniaSimpleApp" x:DataType="app:Composition" Title="{Binding MainViewModel.Title}" - Content="{Binding MainViewModel.Greetings}"/> + Content="{Binding MainViewModel.Greetings}" /> \ No newline at end of file diff --git a/samples/AvaloniaSimpleApp/Repository.cs b/samples/AvaloniaSimpleApp/Repository.cs index 49df169d7..425b09df0 100644 --- a/samples/AvaloniaSimpleApp/Repository.cs +++ b/samples/AvaloniaSimpleApp/Repository.cs @@ -1,6 +1,6 @@ namespace AvaloniaSimpleApp; -public class Repository: IRepository +public class Repository : IRepository { public void RegisterSomething() { diff --git a/samples/AvaloniaSimpleApp/app.manifest b/samples/AvaloniaSimpleApp/app.manifest index 4be7ac419..45e31b930 100644 --- a/samples/AvaloniaSimpleApp/app.manifest +++ b/samples/AvaloniaSimpleApp/app.manifest @@ -1,18 +1,18 @@  - - + + - - - + + + - - - - + + + +