Create .slnx with five projects, wire references (App->Ui->Data, Worker->Data, Tests->Worker+Data), install Avalonia/MVVM/SignalR.Client/ Sqlite/Hosting packages, and add schema.sql per docs/plan.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Templates;
|
|
using ClaudeDo.Ui.ViewModels;
|
|
|
|
namespace ClaudeDo.App;
|
|
|
|
/// <summary>
|
|
/// Given a view model, returns the corresponding view if possible.
|
|
/// </summary>
|
|
[RequiresUnreferencedCode(
|
|
"Default implementation of ViewLocator involves reflection which may be trimmed away.",
|
|
Url = "https://docs.avaloniaui.net/docs/concepts/view-locator")]
|
|
public class ViewLocator : IDataTemplate
|
|
{
|
|
public Control? Build(object? param)
|
|
{
|
|
if (param is null)
|
|
return null;
|
|
|
|
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
|
|
var type = typeof(ViewModelBase).Assembly.GetType(name);
|
|
|
|
if (type != null)
|
|
{
|
|
return (Control)Activator.CreateInstance(type)!;
|
|
}
|
|
|
|
return new TextBlock { Text = "Not Found: " + name };
|
|
}
|
|
|
|
public bool Match(object? data)
|
|
{
|
|
return data is ViewModelBase;
|
|
}
|
|
}
|