code sweep
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
@@ -7,15 +6,12 @@
|
|||||||
<AssemblyName>Toolkit.Foundation.Avalonia</AssemblyName>
|
<AssemblyName>Toolkit.Foundation.Avalonia</AssemblyName>
|
||||||
<RootNamespace>Toolkit.Foundation.Avalonia</RootNamespace>
|
<RootNamespace>Toolkit.Foundation.Avalonia</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
||||||
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview4" />
|
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview4" />
|
||||||
<PackageReference Include="Mediator.Abstractions" Version="2.1.0-preview.5" />
|
<PackageReference Include="Mediator.Abstractions" Version="2.1.0-preview.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Foundation\Foundation.csproj" />
|
<ProjectReference Include="..\Foundation\Foundation.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Mediator;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class CompositeExtension : TriggerExtension
|
||||||
{
|
{
|
||||||
public class CompositeExtension : TriggerExtension
|
|
||||||
{
|
|
||||||
[ConstructorArgument(nameof(Triggers))]
|
[ConstructorArgument(nameof(Triggers))]
|
||||||
public TriggerCollection Triggers { get; } = new TriggerCollection();
|
public TriggerCollection Triggers { get; } = new TriggerCollection();
|
||||||
|
|
||||||
@@ -317,5 +317,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
base.OnInvoked(sender, args);
|
base.OnInvoked(sender, args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using Avalonia.Data.Converters;
|
using Avalonia.Data.Converters;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class EventParameterExtension : MarkupExtension, IEventParameter
|
||||||
{
|
{
|
||||||
public class EventParameterExtension : MarkupExtension, IEventParameter
|
|
||||||
{
|
|
||||||
private readonly IValueConverter? converter;
|
private readonly IValueConverter? converter;
|
||||||
|
|
||||||
private readonly object? converterParameter;
|
private readonly object? converterParameter;
|
||||||
@@ -14,7 +14,6 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
public EventParameterExtension()
|
public EventParameterExtension()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventParameterExtension(string key, string path)
|
public EventParameterExtension(string key, string path)
|
||||||
@@ -61,5 +60,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@ using Avalonia.Markup.Xaml;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class InvokeExtension : TriggerExtension
|
||||||
{
|
{
|
||||||
public class InvokeExtension : TriggerExtension
|
|
||||||
{
|
|
||||||
private static readonly AvaloniaProperty TargetProperty =
|
private static readonly AvaloniaProperty TargetProperty =
|
||||||
AvaloniaProperty.RegisterAttached<InvokeExtension, Control, object>("Target");
|
AvaloniaProperty.RegisterAttached<InvokeExtension, Control, object>("Target");
|
||||||
|
|
||||||
@@ -420,5 +420,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
invoker = default;
|
invoker = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,12 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Data;
|
using Avalonia.Data;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class NavigateExtension : TriggerExtension
|
||||||
{
|
{
|
||||||
public class NavigateExtension : TriggerExtension
|
|
||||||
{
|
|
||||||
private static readonly AttachedProperty<IMediator> MediatorProperty =
|
private static readonly AttachedProperty<IMediator> MediatorProperty =
|
||||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, IMediator>("Mediator");
|
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, IMediator>("Mediator");
|
||||||
|
|
||||||
@@ -481,5 +482,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,12 @@ using Avalonia.Data;
|
|||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class NavigationRouteExtension : MarkupExtension
|
||||||
{
|
{
|
||||||
public class NavigationRouteExtension : MarkupExtension
|
|
||||||
{
|
|
||||||
private static readonly AttachedProperty<IMediator> MediatorProperty =
|
private static readonly AttachedProperty<IMediator> MediatorProperty =
|
||||||
AvaloniaProperty.RegisterAttached<NavigationRouteExtension, Control, IMediator>("Mediator");
|
AvaloniaProperty.RegisterAttached<NavigationRouteExtension, Control, IMediator>("Mediator");
|
||||||
|
|
||||||
@@ -91,5 +92,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia;
|
||||||
using Avalonia;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Data;
|
using Avalonia.Data;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class ParameterBindingExtension : MarkupExtension, IParameter
|
||||||
{
|
{
|
||||||
public class ParameterBindingExtension : MarkupExtension, IParameter
|
|
||||||
{
|
|
||||||
private static readonly AttachedProperty<object> ValueProperty =
|
private static readonly AttachedProperty<object> ValueProperty =
|
||||||
AvaloniaProperty.RegisterAttached<ParameterBindingExtension, Control, object>("Value");
|
AvaloniaProperty.RegisterAttached<ParameterBindingExtension, Control, object>("Value");
|
||||||
|
|
||||||
@@ -38,5 +39,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class TriggerCollection : Collection<Delegate>
|
||||||
{
|
{
|
||||||
public class TriggerCollection : Collection<Delegate>
|
|
||||||
{
|
|
||||||
public void Add(object item)
|
public void Add(object item)
|
||||||
{
|
{
|
||||||
if (item is Delegate trigger)
|
if (item is Delegate trigger)
|
||||||
@@ -11,5 +11,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
base.Add(trigger);
|
base.Add(trigger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class TriggerExtension : MarkupExtension
|
||||||
{
|
{
|
||||||
public class TriggerExtension : MarkupExtension
|
|
||||||
{
|
|
||||||
public AvaloniaObject? TargetObject { get; protected set; }
|
public AvaloniaObject? TargetObject { get; protected set; }
|
||||||
|
|
||||||
protected object? TargetInvoke { get; private set; }
|
protected object? TargetInvoke { get; private set; }
|
||||||
@@ -65,12 +64,9 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
protected virtual void OnAttached(IServiceProvider serviceProvider)
|
protected virtual void OnAttached(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnInvoked(object sender, EventArgs args)
|
protected virtual void OnInvoked(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public record ContentControlNavigation : Navigation<ContentControl>
|
||||||
{
|
{
|
||||||
public record ContentControlNavigation : Navigation<ContentControl>
|
|
||||||
{
|
|
||||||
public ContentControlNavigation(ContentControl route,
|
public ContentControlNavigation(ContentControl route,
|
||||||
object? content,
|
object? content,
|
||||||
object? template,
|
object? template,
|
||||||
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class ContentControlNavigationHandler : IRequestHandler<ContentControlNavigation, bool>
|
||||||
{
|
{
|
||||||
public class ContentControlNavigationHandler : IRequestHandler<ContentControlNavigation, bool>
|
|
||||||
{
|
|
||||||
public async ValueTask<bool> Handle(ContentControlNavigation request, CancellationToken cancellationToken)
|
public async ValueTask<bool> Handle(ContentControlNavigation request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (request.Template is TemplatedControl control)
|
if (request.Template is TemplatedControl control)
|
||||||
@@ -15,5 +15,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public record ContentDialogNavigation : Navigation<ContentDialog>
|
||||||
{
|
{
|
||||||
public record ContentDialogNavigation : Navigation<ContentDialog>
|
|
||||||
{
|
|
||||||
public ContentDialogNavigation(ContentDialog route,
|
public ContentDialogNavigation(ContentDialog route,
|
||||||
object? content,
|
object? content,
|
||||||
object? template,
|
object? template,
|
||||||
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class ContentDialogNavigationHandler : IRequestHandler<ContentDialogNavigation, bool>
|
||||||
{
|
{
|
||||||
public class ContentDialogNavigationHandler : IRequestHandler<ContentDialogNavigation, bool>
|
|
||||||
{
|
|
||||||
public async ValueTask<bool> Handle(ContentDialogNavigation request, CancellationToken cancellationToken)
|
public async ValueTask<bool> Handle(ContentDialogNavigation request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (request.Template is ContentDialog contentDialog)
|
if (request.Template is ContentDialog contentDialog)
|
||||||
@@ -40,5 +40,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public record FrameNavigation : Navigation<Frame>
|
||||||
{
|
{
|
||||||
public record FrameNavigation : Navigation<Frame>
|
|
||||||
{
|
|
||||||
public FrameNavigation(Frame route,
|
public FrameNavigation(Frame route,
|
||||||
object? content,
|
object? content,
|
||||||
object? template,
|
object? template,
|
||||||
@@ -11,5 +11,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
parameters) : base(route, content, template, parameters)
|
parameters) : base(route, content, template, parameters)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
using FluentAvalonia.UI.Navigation;
|
using FluentAvalonia.UI.Navigation;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class FrameNavigationHandler : IRequestHandler<FrameNavigation, bool>
|
||||||
{
|
{
|
||||||
public class FrameNavigationHandler : IRequestHandler<FrameNavigation, bool>
|
|
||||||
{
|
|
||||||
public async ValueTask<bool> Handle(FrameNavigation request, CancellationToken cancellationToken)
|
public async ValueTask<bool> Handle(FrameNavigation request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
request.Route.NavigationPageFactory = new NavigationPageFactory();
|
request.Route.NavigationPageFactory = new NavigationPageFactory();
|
||||||
@@ -29,5 +29,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
return await completionSource.Task;
|
return await completionSource.Task;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,12 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class NavigateBackHandler : IRequestHandler<NavigateBack>
|
||||||
{
|
{
|
||||||
public class NavigateBackHandler : IRequestHandler<NavigateBack>
|
|
||||||
{
|
|
||||||
private readonly INavigationRouteDescriptorCollection descriptors;
|
private readonly INavigationRouteDescriptorCollection descriptors;
|
||||||
|
|
||||||
public NavigateBackHandler(INavigationRouteDescriptorCollection descriptors)
|
public NavigateBackHandler(INavigationRouteDescriptorCollection descriptors)
|
||||||
@@ -34,5 +35,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class NavigateHandler : IRequestHandler<Navigate>
|
||||||
{
|
{
|
||||||
public class NavigateHandler : IRequestHandler<Navigate>
|
|
||||||
{
|
|
||||||
private readonly INavigationRouteDescriptorCollection descriptors;
|
private readonly INavigationRouteDescriptorCollection descriptors;
|
||||||
private readonly IMediator mediator;
|
private readonly IMediator mediator;
|
||||||
private readonly INamedDataTemplateFactory namedDataTemplateFactory;
|
private readonly INamedDataTemplateFactory namedDataTemplateFactory;
|
||||||
@@ -112,5 +113,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public record Navigation<TRoute> : IRequest<bool> where TRoute : TemplatedControl
|
||||||
{
|
{
|
||||||
public record Navigation<TRoute> : IRequest<bool> where TRoute : TemplatedControl
|
|
||||||
{
|
|
||||||
public TRoute Route { get; }
|
public TRoute Route { get; }
|
||||||
|
|
||||||
public Navigation(TRoute route,
|
public Navigation(TRoute route,
|
||||||
@@ -23,5 +23,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
public object? Template { get; }
|
public object? Template { get; }
|
||||||
|
|
||||||
public IDictionary<string, object>? Parameters { get; }
|
public IDictionary<string, object>? Parameters { get; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
internal class NavigationPageFactory : INavigationPageFactory
|
||||||
{
|
{
|
||||||
internal class NavigationPageFactory : INavigationPageFactory
|
|
||||||
{
|
|
||||||
public IControl? GetPage(Type srcType)
|
public IControl? GetPage(Type srcType)
|
||||||
{
|
{
|
||||||
return default;
|
return default;
|
||||||
@@ -14,5 +14,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
{
|
{
|
||||||
return (IControl)target;
|
return (IControl)target;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia;
|
||||||
|
|
||||||
|
public class NavigationRouteHandler : IRequestHandler<NavigationRoute>
|
||||||
{
|
{
|
||||||
public class NavigationRouteHandler : IRequestHandler<NavigationRoute>
|
|
||||||
{
|
|
||||||
private readonly INavigationRouteDescriptorCollection descriptors;
|
private readonly INavigationRouteDescriptorCollection descriptors;
|
||||||
|
|
||||||
public NavigationRouteHandler(INavigationRouteDescriptorCollection descriptors)
|
public NavigationRouteHandler(INavigationRouteDescriptorCollection descriptors)
|
||||||
@@ -35,5 +36,4 @@ namespace Toolkit.Foundation.Avalonia
|
|||||||
descriptors.Add(new NavigationRouteDescriptor(request.Name, request.Route));
|
descriptors.Add(new NavigationRouteDescriptor(request.Name, request.Route));
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Avalonia.Controls.Templates;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls.Templates;
|
||||||
|
using Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation.Avalonia
|
namespace Toolkit.Foundation.Avalonia
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public record ConfigurationChanged<TConfiguration>(TConfiguration Configuration) where TConfiguration : class;
|
public record ConfigurationChanged<TConfiguration>(TConfiguration Configuration) where TConfiguration : class;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class ConfigurationInitializer<TConfiguration> : IInitializable where TConfiguration : class, new()
|
public class ConfigurationInitializer<TConfiguration> : IInitializable where TConfiguration : class, new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class ConfigurationWriter<TConfiguration> : IConfigurationWriter<TConfiguration> where TConfiguration : class, new()
|
public class ConfigurationWriter<TConfiguration> : IConfigurationWriter<TConfiguration> where TConfiguration : class, new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public interface IConfigurationWriter<TConfiguration> where TConfiguration : class
|
public interface IConfigurationWriter<TConfiguration> where TConfiguration : class
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public interface IWritableConfigurationProvider
|
public interface IWritableConfigurationProvider
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public interface IWritableJsonConfigurationBuilder
|
public interface IWritableJsonConfigurationBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public interface IWritableJsonConfigurationDescriptor
|
public interface IWritableJsonConfigurationDescriptor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
using Json.Patch;
|
using Json.Patch;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class WritableJsonConfigurationBuilder : IWritableJsonConfigurationBuilder
|
public class WritableJsonConfigurationBuilder : IWritableJsonConfigurationBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public record WritableJsonConfigurationDescriptor(Type ConfigurationType, string Key) : IWritableJsonConfigurationDescriptor;
|
public record WritableJsonConfigurationDescriptor(Type ConfigurationType, string Key) : IWritableJsonConfigurationDescriptor;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public static class WritableJsonConfigurationExtensions
|
public static class WritableJsonConfigurationExtensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
internal class WritableJsonConfigurationFile
|
internal class WritableJsonConfigurationFile
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ using Microsoft.Extensions.FileProviders;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class WritableJsonConfigurationProvider : JsonConfigurationProvider, IWritableConfigurationProvider
|
public class WritableJsonConfigurationProvider : JsonConfigurationProvider, IWritableConfigurationProvider
|
||||||
{
|
{
|
||||||
public WritableJsonConfigurationProvider(JsonConfigurationSource source) : base(source)
|
public WritableJsonConfigurationProvider(JsonConfigurationSource source) : base(source)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write<TValue>(string section, TValue value) where TValue : class, new()
|
public void Write<TValue>(string section, TValue value) where TValue : class, new()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.Extensions.Configuration.Json;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration.Json;
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class WritableJsonConfigurationSource : JsonConfigurationSource
|
public class WritableJsonConfigurationSource : JsonConfigurationSource
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public abstract record Write<TConfiguration>(string Section, Action<TConfiguration> UpdateDelegate) : IRequest where TConfiguration : class;
|
public abstract record Write<TConfiguration>(string Section, Action<TConfiguration> UpdateDelegate) : IRequest where TConfiguration : class;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class WriteHandler<TConfiguration> : IRequestHandler<Write<TConfiguration>> where TConfiguration : class
|
public class WriteHandler<TConfiguration> : IRequestHandler<Write<TConfiguration>> where TConfiguration : class
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public static class IHostBuilderExtensions
|
public static class IHostBuilderExtensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public static class IServiceCollectionExtensions
|
public static class IServiceCollectionExtensions
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,6 @@ public static class IServiceCollectionExtensions
|
|||||||
return serviceCollection;
|
return serviceCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static IServiceCollection AddFoundation(this IServiceCollection serviceCollection)
|
public static IServiceCollection AddFoundation(this IServiceCollection serviceCollection)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<IServiceFactory>(provider => new ServiceFactory(provider.GetService, (instanceType, parameters) => ActivatorUtilities.CreateInstance(provider, instanceType, parameters!)))
|
serviceCollection.AddSingleton<IServiceFactory>(provider => new ServiceFactory(provider.GetService, (instanceType, parameters) => ActivatorUtilities.CreateInstance(provider, instanceType, parameters!)))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public static class IServiceFactoryExtensions
|
public static class IServiceFactoryExtensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class AppService : IHostedService
|
public class AppService : IHostedService
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public interface ICache
|
public interface ICache
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public interface IInitializable
|
public interface IInitializable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public interface IInitialization
|
public interface IInitialization
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class Initialization : IInitialization
|
public class Initialization : IInitialization
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public record Initialize : IRequest;
|
public record Initialize : IRequest;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public class InitializeHandler : IRequestHandler<Initialize>
|
public class InitializeHandler : IRequestHandler<Initialize>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
public record class Initialized : IRequest;
|
public record class Initialized : IRequest;
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
using System;
|
namespace Toolkit.Foundation;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
public interface IEventParameter
|
||||||
{
|
{
|
||||||
public interface IEventParameter
|
|
||||||
{
|
|
||||||
List<object> GetValues(EventArgs args);
|
List<object> GetValues(EventArgs args);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
|
namespace Toolkit.Foundation;
|
||||||
namespace Toolkit.Foundation
|
|
||||||
{
|
|
||||||
public interface INavigationConfirmation
|
|
||||||
{
|
|
||||||
ValueTask<bool> CanConfirm();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface INavigated
|
public interface INavigationConfirmation
|
||||||
{
|
{
|
||||||
ValueTask Navigated();
|
ValueTask<bool> CanConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface INavigated
|
||||||
|
{
|
||||||
|
ValueTask Navigated();
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface INavigationRouteDescriptor
|
||||||
{
|
{
|
||||||
public interface INavigationRouteDescriptor
|
|
||||||
{
|
|
||||||
object Route { get; }
|
object Route { get; }
|
||||||
|
|
||||||
string? Name { get; }
|
string? Name { get; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
public interface INavigationRouteDescriptorCollection : IList<INavigationRouteDescriptor>
|
||||||
{
|
{
|
||||||
public interface INavigationRouteDescriptorCollection : IList<INavigationRouteDescriptor>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IParameter
|
||||||
{
|
{
|
||||||
public interface IParameter
|
|
||||||
{
|
|
||||||
string? Key { get; }
|
string? Key { get; }
|
||||||
|
|
||||||
KeyValuePair<string, object>? GetValue(object target);
|
KeyValuePair<string, object>? GetValue(object target);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public record Navigate : IRequest
|
||||||
{
|
{
|
||||||
public record Navigate : IRequest
|
|
||||||
{
|
|
||||||
public Navigate(string name, params object?[] parameters)
|
public Navigate(string name, params object?[] parameters)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
@@ -25,5 +25,4 @@ namespace Toolkit.Foundation
|
|||||||
public string? FriendlyName { get; init; }
|
public string? FriendlyName { get; init; }
|
||||||
|
|
||||||
public object?[] Parameters { get; }
|
public object?[] Parameters { get; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
{
|
|
||||||
public record NavigateBack(object Route) : IRequest;
|
|
||||||
|
|
||||||
}
|
public record NavigateBack(object Route) : IRequest;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
{
|
|
||||||
public record NavigationRoute(string Name, object Route) : IRequest;
|
public record NavigationRoute(string Name, object Route) : IRequest;
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public record NavigationRouteDescriptor : INavigationRouteDescriptor
|
||||||
{
|
{
|
||||||
public record NavigationRouteDescriptor : INavigationRouteDescriptor
|
|
||||||
{
|
|
||||||
public NavigationRouteDescriptor(string name, object route)
|
public NavigationRouteDescriptor(string name, object route)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
@@ -11,5 +11,4 @@
|
|||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
public object Route { get; }
|
public object Route { get; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class NavigationRouteDescriptorCollection : List<INavigationRouteDescriptor>, INavigationRouteDescriptorCollection
|
||||||
{
|
{
|
||||||
public class NavigationRouteDescriptorCollection : List<INavigationRouteDescriptor>, INavigationRouteDescriptorCollection
|
|
||||||
{
|
|
||||||
public NavigationRouteDescriptorCollection(IEnumerable<INavigationRouteDescriptor> collection) : base(collection)
|
public NavigationRouteDescriptorCollection(IEnumerable<INavigationRouteDescriptor> collection) : base(collection)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IServiceCreator<T>
|
||||||
{
|
{
|
||||||
public interface IServiceCreator<T>
|
|
||||||
{
|
|
||||||
object Create(Func<Type, object[], object> creator, params object[] parameters);
|
object Create(Func<Type, object[], object> creator, params object[] parameters);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface IServiceFactory
|
||||||
{
|
{
|
||||||
public interface IServiceFactory
|
|
||||||
{
|
|
||||||
object? Create(Type type, params object?[] parameters);
|
object? Create(Type type, params object?[] parameters);
|
||||||
|
|
||||||
T? Create<T>(Type type, params object?[] parameters);
|
T? Create<T>(Type type, params object?[] parameters);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class ServiceCreator<I, T> : IServiceCreator<I>
|
||||||
{
|
{
|
||||||
public class ServiceCreator<I, T> : IServiceCreator<I>
|
|
||||||
{
|
|
||||||
public virtual object Create(Func<Type, object[], object> creator, params object[] parameters)
|
public virtual object Create(Func<Type, object[], object> creator, params object[] parameters)
|
||||||
{
|
{
|
||||||
return creator(typeof(T), parameters);
|
return creator(typeof(T), parameters);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class ServiceFactory : IServiceFactory
|
||||||
{
|
{
|
||||||
public class ServiceFactory : IServiceFactory
|
|
||||||
{
|
|
||||||
private readonly Func<Type, object?> factory;
|
private readonly Func<Type, object?> factory;
|
||||||
private readonly Func<Type, object?[], object> creator;
|
private readonly Func<Type, object?[], object> creator;
|
||||||
|
|
||||||
@@ -22,5 +22,4 @@
|
|||||||
dynamic? lookup = factory(typeof(IServiceCreator<>).MakeGenericType(type));
|
dynamic? lookup = factory(typeof(IServiceCreator<>).MakeGenericType(type));
|
||||||
return lookup is not null ? (T)lookup.Create(creator, parameters) : (T)creator(type, parameters);
|
return lookup is not null ? (T)lookup.Create(creator, parameters) : (T)creator(type, parameters);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
internal class ServiceFactoryDescriptor
|
||||||
{
|
{
|
||||||
internal class ServiceFactoryDescriptor
|
|
||||||
{
|
|
||||||
private readonly IServiceFactory serviceFactory;
|
private readonly IServiceFactory serviceFactory;
|
||||||
|
|
||||||
public ServiceFactoryDescriptor(IServiceFactory serviceFactory)
|
public ServiceFactoryDescriptor(IServiceFactory serviceFactory)
|
||||||
@@ -17,9 +17,8 @@ namespace Toolkit.Foundation
|
|||||||
return methodInfo?.MakeGenericMethod(type).Invoke(this, new object[] { type });
|
return methodInfo?.MakeGenericMethod(type).Invoke(this, new object[] { type });
|
||||||
}
|
}
|
||||||
|
|
||||||
private T Create<T>(Type type)
|
private T? Create<T>(Type type)
|
||||||
{
|
{
|
||||||
return serviceFactory.Create<T>(type);
|
return serviceFactory.Create<T>(type);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface INamedDataTemplateFactory
|
||||||
{
|
{
|
||||||
public interface INamedDataTemplateFactory
|
|
||||||
{
|
|
||||||
object? Create(string name, params object[] parameters);
|
object? Create(string name, params object[] parameters);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface INamedTemplateFactory
|
||||||
{
|
{
|
||||||
public interface INamedTemplateFactory
|
|
||||||
{
|
|
||||||
object? Create(string name);
|
object? Create(string name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface ITemplateBuilder
|
||||||
{
|
{
|
||||||
public interface ITemplateBuilder
|
|
||||||
{
|
|
||||||
IReadOnlyCollection<ITemplateDescriptor> Descriptors { get; }
|
IReadOnlyCollection<ITemplateDescriptor> Descriptors { get; }
|
||||||
|
|
||||||
ITemplateBuilder Add<TViewModel, TView>(string name, ServiceLifetime lifetime = ServiceLifetime.Transient);
|
ITemplateBuilder Add<TViewModel, TView>(string name, ServiceLifetime lifetime = ServiceLifetime.Transient);
|
||||||
|
|
||||||
ITemplateBuilder Add<TViewModel, TView>(ServiceLifetime lifetime = ServiceLifetime.Transient);
|
ITemplateBuilder Add<TViewModel, TView>(ServiceLifetime lifetime = ServiceLifetime.Transient);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface ITemplateDescriptor
|
||||||
{
|
{
|
||||||
public interface ITemplateDescriptor
|
|
||||||
{
|
|
||||||
Type ContentType { get; }
|
Type ContentType { get; }
|
||||||
|
|
||||||
ServiceLifetime Lifetime { get; }
|
ServiceLifetime Lifetime { get; }
|
||||||
@@ -11,5 +11,4 @@ namespace Toolkit.Foundation
|
|||||||
string? Name { get; }
|
string? Name { get; }
|
||||||
|
|
||||||
Type TemplateType { get; }
|
Type TemplateType { get; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
{
|
|
||||||
|
|
||||||
public interface ITemplateDescriptorProvider
|
public interface ITemplateDescriptorProvider
|
||||||
{
|
{
|
||||||
ITemplateDescriptor? Get(string name);
|
ITemplateDescriptor? Get(string name);
|
||||||
|
|
||||||
ITemplateDescriptor? Get(Type type);
|
ITemplateDescriptor? Get(Type type);
|
||||||
|
|
||||||
ITemplateDescriptor? Get<T>();
|
ITemplateDescriptor? Get<T>();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface ITemplateFactory
|
||||||
{
|
{
|
||||||
public interface ITemplateFactory
|
|
||||||
{
|
|
||||||
object? Create([MaybeNull] object? data);
|
object? Create([MaybeNull] object? data);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface ITemplateSelector
|
||||||
{
|
{
|
||||||
public interface ITemplateSelector
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public interface ITypedDataTemplateFactory
|
||||||
{
|
{
|
||||||
public interface ITypedDataTemplateFactory
|
|
||||||
{
|
|
||||||
object? Create(Type type, params object[] parameters);
|
object? Create(Type type, params object[] parameters);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class NamedDataTemplateFactory : INamedDataTemplateFactory
|
||||||
{
|
{
|
||||||
public class NamedDataTemplateFactory : INamedDataTemplateFactory
|
|
||||||
{
|
|
||||||
private readonly Dictionary<string, object> cache = new();
|
private readonly Dictionary<string, object> cache = new();
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||||
@@ -32,5 +32,4 @@
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class NamedTemplateFactory : INamedTemplateFactory
|
||||||
{
|
{
|
||||||
public class NamedTemplateFactory : INamedTemplateFactory
|
|
||||||
{
|
|
||||||
private readonly Dictionary<string, object> cache = new();
|
private readonly Dictionary<string, object> cache = new();
|
||||||
|
|
||||||
private readonly ITemplateDescriptorProvider provider;
|
private readonly ITemplateDescriptorProvider provider;
|
||||||
@@ -37,5 +37,4 @@
|
|||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class TemplateBuilder : ITemplateBuilder
|
||||||
{
|
{
|
||||||
public class TemplateBuilder : ITemplateBuilder
|
|
||||||
{
|
|
||||||
private readonly List<ITemplateDescriptor> descriptors = new();
|
private readonly List<ITemplateDescriptor> descriptors = new();
|
||||||
|
|
||||||
public IReadOnlyCollection<ITemplateDescriptor> Descriptors => new ReadOnlyCollection<ITemplateDescriptor>(descriptors);
|
public IReadOnlyCollection<ITemplateDescriptor> Descriptors => new ReadOnlyCollection<ITemplateDescriptor>(descriptors);
|
||||||
@@ -20,5 +20,4 @@ namespace Toolkit.Foundation
|
|||||||
descriptors.Add(new TemplateDescriptor(typeof(TViewModel), typeof(TView), null, lifetime));
|
descriptors.Add(new TemplateDescriptor(typeof(TViewModel), typeof(TView), null, lifetime));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class TemplateDescriptor : ITemplateDescriptor
|
||||||
{
|
{
|
||||||
public class TemplateDescriptor : ITemplateDescriptor
|
|
||||||
{
|
|
||||||
public TemplateDescriptor(Type dataType,
|
public TemplateDescriptor(Type dataType,
|
||||||
Type templateType,
|
Type templateType,
|
||||||
string? name = null,
|
string? name = null,
|
||||||
@@ -22,5 +22,4 @@ namespace Toolkit.Foundation
|
|||||||
public Type ContentType { get; }
|
public Type ContentType { get; }
|
||||||
|
|
||||||
public string? Name { get; }
|
public string? Name { get; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class TemplateDescriptorProvider : ITemplateDescriptorProvider
|
||||||
{
|
{
|
||||||
public class TemplateDescriptorProvider : ITemplateDescriptorProvider
|
|
||||||
{
|
|
||||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||||
|
|
||||||
public TemplateDescriptorProvider(IReadOnlyCollection<ITemplateDescriptor> descriptors)
|
public TemplateDescriptorProvider(IReadOnlyCollection<ITemplateDescriptor> descriptors)
|
||||||
@@ -38,5 +38,4 @@
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class TemplateFactory : ITemplateFactory
|
||||||
{
|
{
|
||||||
public class TemplateFactory : ITemplateFactory
|
|
||||||
{
|
|
||||||
private readonly Dictionary<object, object> cache = new();
|
private readonly Dictionary<object, object> cache = new();
|
||||||
|
|
||||||
private readonly ITemplateDescriptorProvider provider;
|
private readonly ITemplateDescriptorProvider provider;
|
||||||
@@ -39,5 +39,4 @@ namespace Toolkit.Foundation
|
|||||||
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Toolkit.Foundation
|
namespace Toolkit.Framework.Foundation;
|
||||||
|
|
||||||
|
public class TypedDataTemplateFactory : ITypedDataTemplateFactory
|
||||||
{
|
{
|
||||||
public class TypedDataTemplateFactory : ITypedDataTemplateFactory
|
|
||||||
{
|
|
||||||
private readonly Dictionary<Type, object> cache = new();
|
private readonly Dictionary<Type, object> cache = new();
|
||||||
|
|
||||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||||
@@ -32,5 +32,4 @@
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user