Merge Common to Desktop
This commit is contained in:
parent
26915defe1
commit
e9c6e14965
40 changed files with 447 additions and 282 deletions
10
app/InkForge.Desktop/ReactiveUI/RoutableReactiveObject.cs
Normal file
10
app/InkForge.Desktop/ReactiveUI/RoutableReactiveObject.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using ReactiveUI;
|
||||
|
||||
namespace InkForge.Desktop.ReactiveUI;
|
||||
|
||||
public abstract class RoutableReactiveObject(IScreen screen) : ReactiveObject, IRoutableViewModel
|
||||
{
|
||||
public abstract string? UrlPathSegment { get; }
|
||||
|
||||
public IScreen HostScreen => screen;
|
||||
}
|
||||
23
app/InkForge.Desktop/ReactiveUI/ViewModelFactory.cs
Normal file
23
app/InkForge.Desktop/ReactiveUI/ViewModelFactory.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace InkForge.Desktop.ReactiveUI;
|
||||
|
||||
public interface IViewModelFactory<T, TCreator>
|
||||
{
|
||||
abstract static ObjectFactory<T> CreateObjectFactory();
|
||||
|
||||
abstract static TCreator GetCreator(ObjectFactory<T> factory, IServiceProvider serviceProvider);
|
||||
}
|
||||
|
||||
public class ViewModelFactory<T, TFactory, TCreator>
|
||||
where TFactory : IViewModelFactory<T, TCreator>
|
||||
where TCreator : Delegate
|
||||
{
|
||||
private static ObjectFactory<T>? s_factory;
|
||||
|
||||
public TCreator CreateFactory(IServiceProvider serviceProvider)
|
||||
{
|
||||
s_factory ??= TFactory.CreateObjectFactory();
|
||||
return TFactory.GetCreator(s_factory, serviceProvider);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue