feat: GSS2.Test - UI+DI, Vulkan render test

This commit is contained in:
2026-01-22 08:04:04 +03:00
parent 2ce8d3e966
commit 5af1c508f5
23 changed files with 1093 additions and 131 deletions
@@ -0,0 +1,29 @@
using Avalonia.Controls;
using Avalonia.Controls.Templates;
namespace GSS2.Test;
public class DependencyInjectionViewLocator : IDataTemplate
{
public Control? Build(object? data)
{
if (data is null)
return null;
var name = data.GetType().FullName?.Replace("ViewModel", "View");
if (name is null)
return new TextBlock { Text = $"Not found: {data}" };
var type = Type.GetType(name);
if (type is null)
return new TextBlock { Text = $"Not found type: {name} for {data}" };
var control = Program.ApplicationHost.Services.GetRequiredService(type) as Control;
if (control is null)
return new TextBlock { Text = $"Not found in DI: {type} for {data}" };
control.DataContext = data;
return control;
}
public bool Match(object? data) => data is ViewModelBase;
}