Skip to content

Commit

Permalink
Avalonia example
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Dec 22, 2024
1 parent bb869bd commit 615d76f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
13 changes: 7 additions & 6 deletions samples/AvaloniaSimpleApp/AvaloniaSimpleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand All @@ -11,11 +12,11 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Pure.DI.Core\Pure.DI.Core.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
<ProjectReference Include="..\..\src\Pure.DI\Pure.DI.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
<PackageReference Include="Avalonia" Version="11.2.3" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
<PackageReference Include="Avalonia" Version="11.2.3"/>
<PackageReference Include="Avalonia.Desktop" Version="11.2.3"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3"/>
</ItemGroup>
</Project>
12 changes: 9 additions & 3 deletions samples/AvaloniaSimpleApp/BusinessService.cs
Original file line number Diff line number Diff line change
@@ -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";
}
}
2 changes: 1 addition & 1 deletion samples/AvaloniaSimpleApp/IMainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public interface IMainViewModel
{
string Title { get; }

string Greetings { get; }
}
12 changes: 9 additions & 3 deletions samples/AvaloniaSimpleApp/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -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();
}
2 changes: 1 addition & 1 deletion samples/AvaloniaSimpleApp/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" />
2 changes: 1 addition & 1 deletion samples/AvaloniaSimpleApp/Repository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace AvaloniaSimpleApp;

public class Repository: IRepository
public class Repository : IRepository
{
public void RegisterSomething()
{
Expand Down
26 changes: 13 additions & 13 deletions samples/AvaloniaSimpleApp/app.manifest
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="AvaloniaSimpleApp.Desktop"/>
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="AvaloniaSimpleApp.Desktop"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->

<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>

0 comments on commit 615d76f

Please sign in to comment.