forked from Roflin/gamenight
22 lines
680 B
C#
22 lines
680 B
C#
using System;
|
|
using System.Runtime.Serialization;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Templates;
|
|
using FrontendAvalonia.ViewModels;
|
|
using FrontendAvalonia.Views;
|
|
using ReactiveUI;
|
|
|
|
namespace FrontendAvalonia;
|
|
|
|
public class ViewLocator : IViewLocator
|
|
{
|
|
public IViewFor? ResolveView<T>(T? viewModel, string? contract = null)
|
|
{
|
|
return viewModel switch
|
|
{
|
|
GamenightsViewModel context => new GamenightsView { DataContext = context },
|
|
LoginViewModel context => new LoginView { DataContext = context },
|
|
_ => throw new InvalidOperationException($"Cannot find view for {viewModel?.GetType().Name}")
|
|
};
|
|
}
|
|
} |