code sweep
This commit is contained in:
@@ -5,4 +5,4 @@ namespace Toolkit.Controls.Avalonia;
|
||||
public class NavigationView : FluentAvalonia.UI.Controls.NavigationView, IStyleable
|
||||
{
|
||||
Type IStyleable.StyleKey => typeof(FluentAvalonia.UI.Controls.NavigationView);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
using Avalonia.Metadata;
|
||||
|
||||
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Toolkit.Controls.Avalonia")]
|
||||
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Toolkit.Controls.Avalonia")]
|
||||
@@ -1,21 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>Toolkit.Foundation.Avalonia</AssemblyName>
|
||||
<RootNamespace>Toolkit.Foundation.Avalonia</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview4" />
|
||||
<PackageReference Include="Mediator.Abstractions" Version="2.1.0-preview.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Foundation\Foundation.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>Toolkit.Foundation.Avalonia</AssemblyName>
|
||||
<RootNamespace>Toolkit.Foundation.Avalonia</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview4" />
|
||||
<PackageReference Include="Mediator.Abstractions" Version="2.1.0-preview.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Foundation\Foundation.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -21,4 +21,4 @@ namespace Toolkit.Foundation.Avalonia
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Toolkit.Framework.Foundation;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
@@ -32,4 +32,4 @@ namespace Toolkit.Foundation.Avalonia
|
||||
return hostBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Toolkit.Framework.Foundation;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace Toolkit.Foundation.Avalonia
|
||||
return new Binding { Mode = BindingMode.OneWay, Source = value };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,4 +25,4 @@ namespace Toolkit.Foundation.Avalonia
|
||||
AvaloniaProperty.Register<Dummy, object>("Value");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,321 +1,320 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
namespace Toolkit.Foundation.Avalonia;
|
||||
|
||||
public class CompositeExtension : TriggerExtension
|
||||
{
|
||||
public class CompositeExtension : TriggerExtension
|
||||
[ConstructorArgument(nameof(Triggers))]
|
||||
public TriggerCollection Triggers { get; } = new TriggerCollection();
|
||||
|
||||
public CompositeExtension(object args0)
|
||||
{
|
||||
[ConstructorArgument(nameof(Triggers))]
|
||||
public TriggerCollection Triggers { get; } = new TriggerCollection();
|
||||
Triggers.Add(args0);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0)
|
||||
public CompositeExtension(object args0,
|
||||
object args1)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0, object args1, object args2, object args3, object args4,
|
||||
object args5, object args6, object args7, object args8, object args9, object args10)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0, object args1, object args2, object args3, object args4,
|
||||
object args5, object args6, object args7, object args8, object args9, object args10, object args11)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
Triggers.Add(args13);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
Triggers.Add(args13);
|
||||
Triggers.Add(args14);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14,
|
||||
object args15)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
Triggers.Add(args13);
|
||||
Triggers.Add(args14);
|
||||
Triggers.Add(args15);
|
||||
}
|
||||
|
||||
protected override void OnInvoked(object sender, EventArgs args)
|
||||
{
|
||||
foreach (Delegate? trigger in Triggers)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
trigger.Method.Invoke(trigger.Target, new object[] { sender, args });
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0, object args1, object args2, object args3, object args4,
|
||||
object args5, object args6, object args7, object args8, object args9, object args10)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0, object args1, object args2, object args3, object args4,
|
||||
object args5, object args6, object args7, object args8, object args9, object args10, object args11)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
Triggers.Add(args13);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
Triggers.Add(args13);
|
||||
Triggers.Add(args14);
|
||||
}
|
||||
|
||||
public CompositeExtension(object args0,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14,
|
||||
object args15)
|
||||
{
|
||||
Triggers.Add(args0);
|
||||
Triggers.Add(args1);
|
||||
Triggers.Add(args2);
|
||||
Triggers.Add(args3);
|
||||
Triggers.Add(args4);
|
||||
Triggers.Add(args5);
|
||||
Triggers.Add(args6);
|
||||
Triggers.Add(args7);
|
||||
Triggers.Add(args8);
|
||||
Triggers.Add(args9);
|
||||
Triggers.Add(args10);
|
||||
Triggers.Add(args11);
|
||||
Triggers.Add(args12);
|
||||
Triggers.Add(args13);
|
||||
Triggers.Add(args14);
|
||||
Triggers.Add(args15);
|
||||
}
|
||||
|
||||
protected override void OnInvoked(object sender, EventArgs args)
|
||||
{
|
||||
foreach (Delegate? trigger in Triggers)
|
||||
{
|
||||
trigger.Method.Invoke(trigger.Target, new object[] { sender, args });
|
||||
}
|
||||
|
||||
base.OnInvoked(sender, args);
|
||||
}
|
||||
base.OnInvoked(sender, args);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +1,63 @@
|
||||
using Avalonia.Data.Converters;
|
||||
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 object? converterParameter;
|
||||
|
||||
private readonly string? key;
|
||||
private readonly string? path;
|
||||
|
||||
public EventParameterExtension()
|
||||
{
|
||||
private readonly IValueConverter? converter;
|
||||
}
|
||||
|
||||
private readonly object? converterParameter;
|
||||
public EventParameterExtension(string key, string path)
|
||||
{
|
||||
this.key = key;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
private readonly string? key;
|
||||
private readonly string? path;
|
||||
public EventParameterExtension(string path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public EventParameterExtension()
|
||||
public EventParameterExtension(IValueConverter? converter = null, object? converterParameter = null)
|
||||
{
|
||||
this.converter = converter;
|
||||
this.converterParameter = converterParameter;
|
||||
}
|
||||
|
||||
public List<object> GetValues(EventArgs args)
|
||||
{
|
||||
List<object>? parameters = new();
|
||||
|
||||
dynamic? arguments = args.GetEventArguments(path, converter, converterParameter);
|
||||
if (arguments is not null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EventParameterExtension(string key, string path)
|
||||
{
|
||||
this.key = key;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public EventParameterExtension(string path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public EventParameterExtension(IValueConverter? converter = null, object? converterParameter = null)
|
||||
{
|
||||
this.converter = converter;
|
||||
this.converterParameter = converterParameter;
|
||||
}
|
||||
|
||||
public List<object> GetValues(EventArgs args)
|
||||
{
|
||||
List<object>? parameters = new();
|
||||
|
||||
dynamic? arguments = args.GetEventArguments(path, converter, converterParameter);
|
||||
if (arguments is not null)
|
||||
if (arguments is ICollection<object> collection)
|
||||
{
|
||||
if (arguments is ICollection<object> collection)
|
||||
foreach (object? argument in collection)
|
||||
{
|
||||
foreach (object? argument in collection)
|
||||
{
|
||||
parameters.Add(key is not null ? new KeyValuePair<string, object>(key, (dynamic)argument) : argument);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters.Add(key is not null ? new KeyValuePair<string, object>(key, arguments) : arguments);
|
||||
parameters.Add(key is not null ? new KeyValuePair<string, object>(key, (dynamic)argument) : argument);
|
||||
}
|
||||
}
|
||||
|
||||
return parameters;
|
||||
else
|
||||
{
|
||||
parameters.Add(key is not null ? new KeyValuePair<string, object>(key, arguments) : arguments);
|
||||
}
|
||||
}
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -5,420 +5,419 @@ using Avalonia.Markup.Xaml;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
namespace Toolkit.Foundation.Avalonia;
|
||||
|
||||
public class InvokeExtension : TriggerExtension
|
||||
{
|
||||
public class InvokeExtension : TriggerExtension
|
||||
private static readonly AvaloniaProperty TargetProperty =
|
||||
AvaloniaProperty.RegisterAttached<InvokeExtension, Control, object>("Target");
|
||||
|
||||
private readonly object path;
|
||||
private readonly List<object?> parameters = new();
|
||||
|
||||
public InvokeExtension(object path)
|
||||
{
|
||||
private static readonly AvaloniaProperty TargetProperty =
|
||||
AvaloniaProperty.RegisterAttached<InvokeExtension, Control, object>("Target");
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
private readonly object path;
|
||||
private readonly List<object?> parameters = new();
|
||||
public InvokeExtension(object path,
|
||||
object args1)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
public InvokeExtension(object path)
|
||||
parameters.Add(args1 is not MarkupExtension ? args1.ToBinding() : args1);
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14,
|
||||
object args15)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
parameters.Add(args15 is MarkupExtension ? args15 : args15.ToBinding());
|
||||
}
|
||||
|
||||
protected override void OnInvoked(object sender, EventArgs args)
|
||||
{
|
||||
if (sender is AvaloniaObject avaloniaObject)
|
||||
{
|
||||
this.path = path;
|
||||
CreaterHandler(avaloniaObject, args);
|
||||
}
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1)
|
||||
private void CreaterHandler(AvaloniaObject sender, EventArgs args)
|
||||
{
|
||||
if (TryGetInvoke(sender, out (object? Target, MethodInfo? MethodInfo) invoker))
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is not MarkupExtension ? args1.ToBinding() : args1);
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
}
|
||||
|
||||
public InvokeExtension(object path,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14,
|
||||
object args15)
|
||||
{
|
||||
this.path = path;
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
parameters.Add(args15 is MarkupExtension ? args15 : args15.ToBinding());
|
||||
}
|
||||
|
||||
protected override void OnInvoked(object sender, EventArgs args)
|
||||
{
|
||||
if (sender is AvaloniaObject avaloniaObject)
|
||||
if (invoker.Target is object target)
|
||||
{
|
||||
CreaterHandler(avaloniaObject, args);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreaterHandler(AvaloniaObject sender, EventArgs args)
|
||||
{
|
||||
if (TryGetInvoke(sender, out (object? Target, MethodInfo? MethodInfo) invoker))
|
||||
{
|
||||
if (invoker.Target is object target)
|
||||
if (invoker.MethodInfo is MethodInfo methodInfo)
|
||||
{
|
||||
if (invoker.MethodInfo is MethodInfo methodInfo)
|
||||
ParameterInfo[] parameterInfo = methodInfo.GetParameters();
|
||||
List<object> parameters = new();
|
||||
|
||||
foreach (object? parameter in this.parameters)
|
||||
{
|
||||
ParameterInfo[] parameterInfo = methodInfo.GetParameters();
|
||||
List<object> parameters = new();
|
||||
|
||||
foreach (object? parameter in this.parameters)
|
||||
switch (parameter)
|
||||
{
|
||||
switch (parameter)
|
||||
{
|
||||
//case IParameter keyedParameter:
|
||||
// BindingOperations.SetBinding(sender, ParameterProperty, parameter.ToBinding());
|
||||
// parameters.Add(new KeyValuePair<string, object>(keyedParameter.Key, (dynamic)sender.GetValue(ParameterProperty)));
|
||||
// break;
|
||||
//case IEventParameter eventParameter:
|
||||
// parameters.AddRange(eventParameter.GetParameters(args));
|
||||
// break;
|
||||
//default:
|
||||
// BindingOperations.SetBinding(sender, ParameterProperty, parameter.ToBinding());
|
||||
// parameters.Add((dynamic)sender.GetValue(ParameterProperty));
|
||||
// break;
|
||||
}
|
||||
//case IParameter keyedParameter:
|
||||
// BindingOperations.SetBinding(sender, ParameterProperty, parameter.ToBinding());
|
||||
// parameters.Add(new KeyValuePair<string, object>(keyedParameter.Key, (dynamic)sender.GetValue(ParameterProperty)));
|
||||
// break;
|
||||
//case IEventParameter eventParameter:
|
||||
// parameters.AddRange(eventParameter.GetParameters(args));
|
||||
// break;
|
||||
//default:
|
||||
// BindingOperations.SetBinding(sender, ParameterProperty, parameter.ToBinding());
|
||||
// parameters.Add((dynamic)sender.GetValue(ParameterProperty));
|
||||
// break;
|
||||
}
|
||||
|
||||
methodInfo.Invoke(target, parameters.Any() ? parameters.ToArray() : parameterInfo.Length > 0 ? new object?[] { null } : Array.Empty<object>());
|
||||
}
|
||||
|
||||
methodInfo.Invoke(target, parameters.Any() ? parameters.ToArray() : parameterInfo.Length > 0 ? new object?[] { null } : Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetInvoke(AvaloniaObject sender, [AllowNull] out (object?, MethodInfo?) invoker)
|
||||
private bool TryGetInvoke(AvaloniaObject sender, [AllowNull] out (object?, MethodInfo?) invoker)
|
||||
{
|
||||
if (path is Binding binding)
|
||||
{
|
||||
if (path is Binding binding)
|
||||
sender.Bind(TargetProperty, binding);
|
||||
if (sender.GetValue(TargetProperty) is Action action)
|
||||
{
|
||||
sender.Bind(TargetProperty, binding);
|
||||
if (sender.GetValue(TargetProperty) is Action action)
|
||||
invoker = new(action.Target, action.Method);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (path is string name)
|
||||
{
|
||||
if (sender.GetValue(StyledElement.DataContextProperty) is object dataContext)
|
||||
{
|
||||
if (dataContext.GetType().GetMethod(name, BindingFlags.Public | BindingFlags.Instance) is MethodInfo methodInfo)
|
||||
{
|
||||
invoker = new(action.Target, action.Method);
|
||||
invoker = new(dataContext, methodInfo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (path is string name)
|
||||
{
|
||||
if (sender.GetValue(StyledElement.DataContextProperty) is object dataContext)
|
||||
{
|
||||
if (dataContext.GetType().GetMethod(name, BindingFlags.Public | BindingFlags.Instance) is MethodInfo methodInfo)
|
||||
{
|
||||
invoker = new(dataContext, methodInfo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
invoker = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
invoker = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3,482 +3,482 @@ using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Markup.Xaml;
|
||||
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 =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, IMediator>("Mediator");
|
||||
|
||||
private static readonly AttachedProperty<object> ParameterProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, object>("Parameter");
|
||||
|
||||
private static readonly AvaloniaProperty RouteProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, object>("Route");
|
||||
|
||||
private static readonly AvaloniaProperty ToProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, object>("To");
|
||||
|
||||
private readonly Binding? mediatorBinding;
|
||||
private readonly List<object?> parameters = new();
|
||||
private readonly Binding? toBinding;
|
||||
private object? route;
|
||||
private Binding? routeBinding;
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to)
|
||||
{
|
||||
private static readonly AttachedProperty<IMediator> MediatorProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, IMediator>("Mediator");
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
}
|
||||
|
||||
private static readonly AttachedProperty<object> ParameterProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, object>("Parameter");
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
private static readonly AvaloniaProperty RouteProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, object>("Route");
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
}
|
||||
|
||||
private static readonly AvaloniaProperty ToProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigateExtension, Control, object>("To");
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
private readonly Binding? mediatorBinding;
|
||||
private readonly List<object?> parameters = new();
|
||||
private readonly Binding? toBinding;
|
||||
private object? route;
|
||||
private Binding? routeBinding;
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to)
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14,
|
||||
object args15)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
parameters.Add(args15 is MarkupExtension ? args15 : args15.ToBinding());
|
||||
}
|
||||
|
||||
public object? Route
|
||||
{
|
||||
get
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
return route;
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1)
|
||||
set
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
}
|
||||
|
||||
public NavigateExtension(object mediator,
|
||||
object to,
|
||||
object args1,
|
||||
object args2,
|
||||
object args3,
|
||||
object args4,
|
||||
object args5,
|
||||
object args6,
|
||||
object args7,
|
||||
object args8,
|
||||
object args9,
|
||||
object args10,
|
||||
object args11,
|
||||
object args12,
|
||||
object args13,
|
||||
object args14,
|
||||
object args15)
|
||||
{
|
||||
mediatorBinding = mediator.ToBinding();
|
||||
this.toBinding = to is Binding toBinding ? toBinding : to.ToBinding();
|
||||
|
||||
parameters.Add(args1 is MarkupExtension ? args1 : args1.ToBinding());
|
||||
parameters.Add(args2 is MarkupExtension ? args2 : args2.ToBinding());
|
||||
parameters.Add(args3 is MarkupExtension ? args3 : args3.ToBinding());
|
||||
parameters.Add(args4 is MarkupExtension ? args4 : args4.ToBinding());
|
||||
parameters.Add(args5 is MarkupExtension ? args5 : args5.ToBinding());
|
||||
parameters.Add(args6 is MarkupExtension ? args6 : args6.ToBinding());
|
||||
parameters.Add(args7 is MarkupExtension ? args7 : args7.ToBinding());
|
||||
parameters.Add(args8 is MarkupExtension ? args8 : args8.ToBinding());
|
||||
parameters.Add(args9 is MarkupExtension ? args9 : args9.ToBinding());
|
||||
parameters.Add(args10 is MarkupExtension ? args10 : args10.ToBinding());
|
||||
parameters.Add(args11 is MarkupExtension ? args11 : args11.ToBinding());
|
||||
parameters.Add(args12 is MarkupExtension ? args12 : args12.ToBinding());
|
||||
parameters.Add(args13 is MarkupExtension ? args13 : args13.ToBinding());
|
||||
parameters.Add(args14 is MarkupExtension ? args14 : args14.ToBinding());
|
||||
parameters.Add(args15 is MarkupExtension ? args15 : args15.ToBinding());
|
||||
}
|
||||
|
||||
public object? Route
|
||||
{
|
||||
get
|
||||
route = value;
|
||||
if (route is not null)
|
||||
{
|
||||
return route;
|
||||
routeBinding = route.ToBinding();
|
||||
}
|
||||
set
|
||||
{
|
||||
route = value;
|
||||
if (route is not null)
|
||||
{
|
||||
routeBinding = route.ToBinding();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInvoked(object sender, EventArgs args)
|
||||
}
|
||||
|
||||
protected override void OnInvoked(object sender, EventArgs args)
|
||||
{
|
||||
if (TargetObject is not null)
|
||||
{
|
||||
if (TargetObject is not null)
|
||||
if (mediatorBinding is not null)
|
||||
{
|
||||
if (mediatorBinding is not null)
|
||||
TargetObject.Bind(MediatorProperty, mediatorBinding);
|
||||
if (TargetObject.GetValue(MediatorProperty) is IMediator mediator)
|
||||
{
|
||||
TargetObject.Bind(MediatorProperty, mediatorBinding);
|
||||
if (TargetObject.GetValue(MediatorProperty) is IMediator mediator)
|
||||
if (toBinding is not null)
|
||||
{
|
||||
if (toBinding is not null)
|
||||
TargetObject.Bind(ToProperty, toBinding);
|
||||
if (TargetObject.GetValue(ToProperty) is { } to)
|
||||
{
|
||||
TargetObject.Bind(ToProperty, toBinding);
|
||||
if (TargetObject.GetValue(ToProperty) is { } to)
|
||||
List<object>? parameters = new();
|
||||
foreach (object? parameter in this.parameters)
|
||||
{
|
||||
List<object>? parameters = new();
|
||||
foreach (object? parameter in this.parameters)
|
||||
if (parameter is not null)
|
||||
{
|
||||
if (parameter is not null)
|
||||
switch (parameter)
|
||||
{
|
||||
switch (parameter)
|
||||
{
|
||||
case IParameter keyedParameter:
|
||||
if (keyedParameter.GetValue(TargetObject) is KeyValuePair<string, object> keyValuePair)
|
||||
{
|
||||
parameters.Add(keyValuePair);
|
||||
}
|
||||
break;
|
||||
case IEventParameter eventParameter:
|
||||
parameters.AddRange(eventParameter.GetValues(args));
|
||||
break;
|
||||
default:
|
||||
if (parameter.ToBinding() is Binding defaultDinding)
|
||||
{
|
||||
TargetObject.Bind(ParameterProperty, defaultDinding);
|
||||
parameters.Add((dynamic)TargetObject.GetValue(ParameterProperty));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IParameter keyedParameter:
|
||||
if (keyedParameter.GetValue(TargetObject) is KeyValuePair<string, object> keyValuePair)
|
||||
{
|
||||
parameters.Add(keyValuePair);
|
||||
}
|
||||
break;
|
||||
case IEventParameter eventParameter:
|
||||
parameters.AddRange(eventParameter.GetValues(args));
|
||||
break;
|
||||
default:
|
||||
if (parameter.ToBinding() is Binding defaultDinding)
|
||||
{
|
||||
TargetObject.Bind(ParameterProperty, defaultDinding);
|
||||
parameters.Add((dynamic)TargetObject.GetValue(ParameterProperty));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
object? route = null;
|
||||
if (routeBinding is not null)
|
||||
{
|
||||
TargetObject.Bind(RouteProperty, routeBinding);
|
||||
route = TargetObject.GetValue(RouteProperty);
|
||||
}
|
||||
|
||||
if (to is string name)
|
||||
{
|
||||
if (toBinding?.StringFormat is string format)
|
||||
{
|
||||
name = string.Format(format, name);
|
||||
}
|
||||
|
||||
mediator.Send(new Navigate(name, parameters.ToArray()) { Route = route });
|
||||
}
|
||||
|
||||
if (to is Type type)
|
||||
{
|
||||
mediator.Send(new Navigate(type, parameters.ToArray()) { Route = route });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object? route = null;
|
||||
if (routeBinding is not null)
|
||||
{
|
||||
TargetObject.Bind(RouteProperty, routeBinding);
|
||||
route = TargetObject.GetValue(RouteProperty);
|
||||
}
|
||||
|
||||
if (to is string name)
|
||||
{
|
||||
if (toBinding?.StringFormat is string format)
|
||||
{
|
||||
name = string.Format(format, name);
|
||||
}
|
||||
|
||||
mediator.Send(new Navigate(name, parameters.ToArray()) { Route = route });
|
||||
}
|
||||
|
||||
if (to is Type type)
|
||||
{
|
||||
mediator.Send(new Navigate(type, parameters.ToArray()) { Route = route });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnInvoked(sender, args);
|
||||
}
|
||||
|
||||
base.OnInvoked(sender, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,91 +5,91 @@ using Avalonia.Data;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
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 =
|
||||
AvaloniaProperty.RegisterAttached<NavigationRouteExtension, Control, IMediator>("Mediator");
|
||||
|
||||
private readonly string name;
|
||||
private readonly Binding? mediatorBinding;
|
||||
|
||||
public NavigationRouteExtension(object mediator, string name)
|
||||
{
|
||||
private static readonly AttachedProperty<IMediator> MediatorProperty =
|
||||
AvaloniaProperty.RegisterAttached<NavigationRouteExtension, Control, IMediator>("Mediator");
|
||||
mediatorBinding = mediator is Binding toBinding ? toBinding : mediator.ToBinding();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private readonly string name;
|
||||
private readonly Binding? mediatorBinding;
|
||||
private bool TryGetBinding(AvaloniaObject sender, out object? binding)
|
||||
{
|
||||
binding = sender.GetValue(StyledElement.DataContextProperty);
|
||||
return binding is not null;
|
||||
}
|
||||
|
||||
public NavigationRouteExtension(object mediator, string name)
|
||||
public override object? ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget target)
|
||||
{
|
||||
mediatorBinding = mediator is Binding toBinding ? toBinding : mediator.ToBinding();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private bool TryGetBinding(AvaloniaObject sender, out object? binding)
|
||||
{
|
||||
binding = sender.GetValue(StyledElement.DataContextProperty);
|
||||
return binding is not null;
|
||||
}
|
||||
|
||||
public override object? ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget target)
|
||||
if (target.TargetObject is TemplatedControl control)
|
||||
{
|
||||
if (target.TargetObject is TemplatedControl control)
|
||||
if (!TryGetBinding(control, out object? binding))
|
||||
{
|
||||
if (!TryGetBinding(control, out object? binding))
|
||||
void HandleDataContextChanged(object? sender, EventArgs args)
|
||||
{
|
||||
void HandleDataContextChanged(object? sender, EventArgs args)
|
||||
{
|
||||
if (TryGetBinding(control, out binding))
|
||||
{
|
||||
control.Loaded -= HandleLoaded;
|
||||
if (mediatorBinding is not null)
|
||||
{
|
||||
control.Bind(MediatorProperty, mediatorBinding);
|
||||
if (control.GetValue(MediatorProperty) is IMediator mediator)
|
||||
{
|
||||
mediator.Send(new NavigationRoute(name, control));
|
||||
control.ClearValue(MediatorProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
control.DataContextChanged += HandleDataContextChanged;
|
||||
|
||||
void HandleLoaded(object? sender, RoutedEventArgs args)
|
||||
if (TryGetBinding(control, out binding))
|
||||
{
|
||||
control.Loaded -= HandleLoaded;
|
||||
if (TryGetBinding(control, out binding))
|
||||
if (mediatorBinding is not null)
|
||||
{
|
||||
if (mediatorBinding is not null)
|
||||
control.Bind(MediatorProperty, mediatorBinding);
|
||||
if (control.GetValue(MediatorProperty) is IMediator mediator)
|
||||
{
|
||||
control.Bind(MediatorProperty, mediatorBinding);
|
||||
if (control.GetValue(MediatorProperty) is IMediator mediator)
|
||||
{
|
||||
mediator.Send(new NavigationRoute(name, control));
|
||||
control.ClearValue(MediatorProperty);
|
||||
}
|
||||
mediator.Send(new NavigationRoute(name, control));
|
||||
control.ClearValue(MediatorProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
control.Loaded += HandleLoaded;
|
||||
}
|
||||
else
|
||||
|
||||
control.DataContextChanged += HandleDataContextChanged;
|
||||
|
||||
void HandleLoaded(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
if (mediatorBinding is not null)
|
||||
control.Loaded -= HandleLoaded;
|
||||
if (TryGetBinding(control, out binding))
|
||||
{
|
||||
control.Bind(MediatorProperty, mediatorBinding);
|
||||
if (control.GetValue(MediatorProperty) is IMediator mediator)
|
||||
if (mediatorBinding is not null)
|
||||
{
|
||||
mediator.Send(new NavigationRoute(name, control));
|
||||
control.ClearValue(MediatorProperty);
|
||||
control.Bind(MediatorProperty, mediatorBinding);
|
||||
if (control.GetValue(MediatorProperty) is IMediator mediator)
|
||||
{
|
||||
mediator.Send(new NavigationRoute(name, control));
|
||||
control.ClearValue(MediatorProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
control.Loaded += HandleLoaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mediatorBinding is not null)
|
||||
{
|
||||
control.Bind(MediatorProperty, mediatorBinding);
|
||||
if (control.GetValue(MediatorProperty) is IMediator mediator)
|
||||
{
|
||||
mediator.Send(new NavigationRoute(name, control));
|
||||
control.ClearValue(MediatorProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,42 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
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 =
|
||||
AvaloniaProperty.RegisterAttached<ParameterBindingExtension, Control, object>("Value");
|
||||
|
||||
private readonly Binding? valueBinding;
|
||||
|
||||
public ParameterBindingExtension(string key, object value)
|
||||
{
|
||||
private static readonly AttachedProperty<object> ValueProperty =
|
||||
AvaloniaProperty.RegisterAttached<ParameterBindingExtension, Control, object>("Value");
|
||||
|
||||
private readonly Binding? valueBinding;
|
||||
|
||||
public ParameterBindingExtension(string key, object value)
|
||||
{
|
||||
Key = key;
|
||||
valueBinding = value.ToBinding();
|
||||
}
|
||||
|
||||
public string? Key { get; }
|
||||
|
||||
public KeyValuePair<string, object>? GetValue(object target)
|
||||
{
|
||||
if (target is AvaloniaObject avaloniaObject)
|
||||
{
|
||||
if (valueBinding is not null)
|
||||
{
|
||||
avaloniaObject.Bind(ValueProperty, valueBinding);
|
||||
return new KeyValuePair<string, object>(Key, (dynamic)avaloniaObject.GetValue(ValueProperty));
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
Key = key;
|
||||
valueBinding = value.ToBinding();
|
||||
}
|
||||
}
|
||||
|
||||
public string? Key { get; }
|
||||
|
||||
public KeyValuePair<string, object>? GetValue(object target)
|
||||
{
|
||||
if (target is AvaloniaObject avaloniaObject)
|
||||
{
|
||||
if (valueBinding is not null)
|
||||
{
|
||||
avaloniaObject.Bind(ValueProperty, valueBinding);
|
||||
return new KeyValuePair<string, object>(Key, (dynamic)avaloniaObject.GetValue(ValueProperty));
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
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)
|
||||
{
|
||||
base.Add(trigger);
|
||||
}
|
||||
base.Add(trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +1,72 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
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; }
|
||||
|
||||
protected object? TargetInvoke { get; private set; }
|
||||
|
||||
public void Invoke(object sender, EventArgs args)
|
||||
{
|
||||
public AvaloniaObject? TargetObject { get; protected set; }
|
||||
OnInvoked(sender, args);
|
||||
}
|
||||
|
||||
protected object? TargetInvoke { get; private set; }
|
||||
|
||||
public void Invoke(object sender, EventArgs args)
|
||||
public override object? ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget target)
|
||||
{
|
||||
OnInvoked(sender, args);
|
||||
}
|
||||
|
||||
public override object? ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget target)
|
||||
if (target.TargetObject is AvaloniaObject avaloniaObject)
|
||||
{
|
||||
if (target.TargetObject is AvaloniaObject avaloniaObject)
|
||||
TargetObject = avaloniaObject;
|
||||
}
|
||||
else if (serviceProvider.GetService(typeof(IRootObjectProvider)) is IRootObjectProvider root)
|
||||
{
|
||||
TargetObject = (AvaloniaObject)root.RootObject;
|
||||
}
|
||||
|
||||
if (TargetObject is not null)
|
||||
{
|
||||
string? targetName = target.TargetProperty as string;
|
||||
|
||||
TargetInvoke = target.TargetProperty;
|
||||
OnAttached(serviceProvider);
|
||||
|
||||
EventInfo? eventInfo = target.TargetProperty as EventInfo ?? (targetName is not null ? TargetObject.GetType().GetEvent(targetName) : null);
|
||||
MethodInfo? methodInfo = eventInfo is not null ? null : target.TargetProperty as MethodInfo ?? (targetName is not null ? TargetObject.GetType().GetMethod(targetName) : null);
|
||||
|
||||
MethodInfo invokeMethod = GetType().GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public)!;
|
||||
if (invokeMethod is null)
|
||||
{
|
||||
TargetObject = avaloniaObject;
|
||||
}
|
||||
else if (serviceProvider.GetService(typeof(IRootObjectProvider)) is IRootObjectProvider root)
|
||||
{
|
||||
TargetObject = (AvaloniaObject)root.RootObject;
|
||||
return this;
|
||||
}
|
||||
|
||||
if (TargetObject is not null)
|
||||
if (eventInfo is not null)
|
||||
{
|
||||
string? targetName = target.TargetProperty as string;
|
||||
return Delegate.CreateDelegate(eventInfo.EventHandlerType!, this, invokeMethod);
|
||||
}
|
||||
|
||||
TargetInvoke = target.TargetProperty;
|
||||
OnAttached(serviceProvider);
|
||||
|
||||
EventInfo? eventInfo = target.TargetProperty as EventInfo ?? (targetName is not null ? TargetObject.GetType().GetEvent(targetName) : null);
|
||||
MethodInfo? methodInfo = eventInfo is not null ? null : target.TargetProperty as MethodInfo ?? (targetName is not null ? TargetObject.GetType().GetMethod(targetName) : null);
|
||||
|
||||
MethodInfo invokeMethod = GetType().GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public)!;
|
||||
if (invokeMethod is null)
|
||||
if (methodInfo is not null)
|
||||
{
|
||||
if (methodInfo.GetParameters() is ParameterInfo[] methodParameters && methodParameters is { Length: 2 })
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (eventInfo is not null)
|
||||
{
|
||||
return Delegate.CreateDelegate(eventInfo.EventHandlerType!, this, invokeMethod);
|
||||
}
|
||||
|
||||
if (methodInfo is not null)
|
||||
{
|
||||
if (methodInfo.GetParameters() is ParameterInfo[] methodParameters && methodParameters is { Length: 2 })
|
||||
{
|
||||
return Delegate.CreateDelegate(methodParameters[1].ParameterType, this, invokeMethod);
|
||||
}
|
||||
return Delegate.CreateDelegate(methodParameters[1].ParameterType, this, invokeMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual void OnAttached(IServiceProvider serviceProvider)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
namespace Toolkit.Foundation.Avalonia;
|
||||
|
||||
public record ContentControlNavigation : Navigation<ContentControl>
|
||||
{
|
||||
public record ContentControlNavigation : Navigation<ContentControl>
|
||||
public ContentControlNavigation(ContentControl route,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
||||
{
|
||||
public ContentControlNavigation(ContentControl route,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Mediator;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
public class ContentControlNavigationHandler : IRequestHandler<ContentControlNavigation, bool>
|
||||
{
|
||||
public async ValueTask<bool> Handle(ContentControlNavigation request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Template is TemplatedControl control)
|
||||
{
|
||||
control.DataContext = request.Content;
|
||||
request.Route.Content = control;
|
||||
}
|
||||
namespace Toolkit.Foundation.Avalonia;
|
||||
|
||||
return await Task.FromResult(true);
|
||||
public class ContentControlNavigationHandler : IRequestHandler<ContentControlNavigation, bool>
|
||||
{
|
||||
public async ValueTask<bool> Handle(ContentControlNavigation request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Template is TemplatedControl control)
|
||||
{
|
||||
control.DataContext = request.Content;
|
||||
request.Route.Content = control;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
using FluentAvalonia.UI.Controls;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
public record ContentDialogNavigation : Navigation<ContentDialog>
|
||||
{
|
||||
public ContentDialogNavigation(ContentDialog route,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
||||
{
|
||||
namespace Toolkit.Foundation.Avalonia;
|
||||
|
||||
}
|
||||
public record ContentDialogNavigation : Navigation<ContentDialog>
|
||||
{
|
||||
public ContentDialogNavigation(ContentDialog route,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>? parameters) : base(route, content, template, parameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,43 @@
|
||||
using FluentAvalonia.UI.Controls;
|
||||
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)
|
||||
async void HandleButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
async void HandleButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
ContentDialogButtonClickDeferral defferal = args.GetDeferral();
|
||||
if (sender.DataContext is INavigationConfirmation confirmation)
|
||||
{
|
||||
ContentDialogButtonClickDeferral defferal = args.GetDeferral();
|
||||
if (sender.DataContext is INavigationConfirmation confirmation)
|
||||
if (!await confirmation.CanConfirm())
|
||||
{
|
||||
if (!await confirmation.CanConfirm())
|
||||
{
|
||||
args.Cancel = true;
|
||||
}
|
||||
args.Cancel = true;
|
||||
}
|
||||
|
||||
if (!args.Cancel)
|
||||
{
|
||||
contentDialog.SecondaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.CloseButtonClick -= HandleButtonClick;
|
||||
}
|
||||
|
||||
defferal.Complete();
|
||||
}
|
||||
|
||||
contentDialog.SecondaryButtonClick += HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick += HandleButtonClick;
|
||||
contentDialog.CloseButtonClick += HandleButtonClick;
|
||||
if (!args.Cancel)
|
||||
{
|
||||
contentDialog.SecondaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.CloseButtonClick -= HandleButtonClick;
|
||||
}
|
||||
|
||||
contentDialog.DataContext = request.Content;
|
||||
await contentDialog.ShowAsync();
|
||||
defferal.Complete();
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
contentDialog.SecondaryButtonClick += HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick += HandleButtonClick;
|
||||
contentDialog.CloseButtonClick += HandleButtonClick;
|
||||
|
||||
contentDialog.DataContext = request.Content;
|
||||
await contentDialog.ShowAsync();
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
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,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>?
|
||||
parameters) : base(route, content, template, parameters)
|
||||
{
|
||||
public FrameNavigation(Frame route,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>?
|
||||
parameters) : base(route, content, template, parameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,32 +2,31 @@
|
||||
using FluentAvalonia.UI.Navigation;
|
||||
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();
|
||||
|
||||
TaskCompletionSource<bool> completionSource = new();
|
||||
if (request.Template is TemplatedControl content)
|
||||
{
|
||||
request.Route.NavigationPageFactory = new NavigationPageFactory();
|
||||
|
||||
TaskCompletionSource<bool> completionSource = new();
|
||||
if (request.Template is TemplatedControl content)
|
||||
void HandleNavigated(object sender, NavigationEventArgs args)
|
||||
{
|
||||
void HandleNavigated(object sender, NavigationEventArgs args)
|
||||
request.Route.Navigated -= HandleNavigated;
|
||||
if (request.Route.Content is TemplatedControl control)
|
||||
{
|
||||
request.Route.Navigated -= HandleNavigated;
|
||||
if (request.Route.Content is TemplatedControl control)
|
||||
{
|
||||
control.DataContext = request.Content;
|
||||
completionSource.SetResult(true);
|
||||
}
|
||||
control.DataContext = request.Content;
|
||||
completionSource.SetResult(true);
|
||||
}
|
||||
|
||||
request.Route.Navigated += HandleNavigated;
|
||||
request.Route.NavigateFromObject(content);
|
||||
}
|
||||
|
||||
return await completionSource.Task;
|
||||
request.Route.Navigated += HandleNavigated;
|
||||
request.Route.NavigateFromObject(content);
|
||||
}
|
||||
|
||||
return await completionSource.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,37 +2,37 @@
|
||||
using Avalonia.Controls.Primitives;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
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;
|
||||
|
||||
public NavigateBackHandler(INavigationRouteDescriptorCollection descriptors)
|
||||
{
|
||||
private readonly INavigationRouteDescriptorCollection descriptors;
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public NavigateBackHandler(INavigationRouteDescriptorCollection descriptors)
|
||||
public ValueTask<Unit> Handle(NavigateBack request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => request.Route is string { } name && name == x.Name) is NavigationRouteDescriptor descriptor)
|
||||
{
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public ValueTask<Unit> Handle(NavigateBack request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => request.Route is string { } name && name == x.Name) is NavigationRouteDescriptor descriptor)
|
||||
if (descriptor.Route is ContentControl { Content: TemplatedControl content })
|
||||
{
|
||||
if (descriptor.Route is ContentControl { Content: TemplatedControl content })
|
||||
if (content.DataContext is IDisposable disposable)
|
||||
{
|
||||
if (content.DataContext is IDisposable disposable)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor.Route is Frame frame)
|
||||
{
|
||||
frame.GoBack();
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
if (descriptor.Route is Frame frame)
|
||||
{
|
||||
frame.GoBack();
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +1,116 @@
|
||||
using Avalonia.Controls;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
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 IMediator mediator;
|
||||
private readonly INamedDataTemplateFactory namedDataTemplateFactory;
|
||||
private readonly INamedTemplateFactory namedTemplateFactory;
|
||||
private readonly ITemplateFactory templateFactory;
|
||||
private readonly ITypedDataTemplateFactory typedDataTemplateFactory;
|
||||
|
||||
public NavigateHandler(IMediator mediator,
|
||||
ITemplateFactory templateFactory,
|
||||
INamedTemplateFactory namedTemplateFactory,
|
||||
INamedDataTemplateFactory namedDataTemplateFactory,
|
||||
ITypedDataTemplateFactory typedDataTemplateFactory,
|
||||
INavigationRouteDescriptorCollection descriptors)
|
||||
{
|
||||
private readonly INavigationRouteDescriptorCollection descriptors;
|
||||
private readonly IMediator mediator;
|
||||
private readonly INamedDataTemplateFactory namedDataTemplateFactory;
|
||||
private readonly INamedTemplateFactory namedTemplateFactory;
|
||||
private readonly ITemplateFactory templateFactory;
|
||||
private readonly ITypedDataTemplateFactory typedDataTemplateFactory;
|
||||
this.mediator = mediator;
|
||||
this.templateFactory = templateFactory;
|
||||
this.namedTemplateFactory = namedTemplateFactory;
|
||||
this.namedDataTemplateFactory = namedDataTemplateFactory;
|
||||
this.typedDataTemplateFactory = typedDataTemplateFactory;
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public NavigateHandler(IMediator mediator,
|
||||
ITemplateFactory templateFactory,
|
||||
INamedTemplateFactory namedTemplateFactory,
|
||||
INamedDataTemplateFactory namedDataTemplateFactory,
|
||||
ITypedDataTemplateFactory typedDataTemplateFactory,
|
||||
INavigationRouteDescriptorCollection descriptors)
|
||||
public async ValueTask<Unit> Handle(Navigate request, CancellationToken cancellationToken)
|
||||
{
|
||||
object? content = null;
|
||||
object? template = null;
|
||||
|
||||
Dictionary<string, object> keyedParameters = new();
|
||||
List<object> parameters = new();
|
||||
|
||||
foreach (object? parameter in request.Parameters)
|
||||
{
|
||||
this.mediator = mediator;
|
||||
this.templateFactory = templateFactory;
|
||||
this.namedTemplateFactory = namedTemplateFactory;
|
||||
this.namedDataTemplateFactory = namedDataTemplateFactory;
|
||||
this.typedDataTemplateFactory = typedDataTemplateFactory;
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public async ValueTask<Unit> Handle(Navigate request, CancellationToken cancellationToken)
|
||||
{
|
||||
object? content = null;
|
||||
object? template = null;
|
||||
|
||||
Dictionary<string, object> keyedParameters = new();
|
||||
List<object> parameters = new();
|
||||
|
||||
foreach (object? parameter in request.Parameters)
|
||||
if (parameter is not null)
|
||||
{
|
||||
if (parameter is not null)
|
||||
if (parameter is KeyValuePair<string, object> keyed)
|
||||
{
|
||||
if (parameter is KeyValuePair<string, object> keyed)
|
||||
{
|
||||
keyedParameters.Add(keyed.Key, keyed.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (request.Name is { Length: > 0 } name)
|
||||
{
|
||||
content = namedDataTemplateFactory.Create(name, parameters.ToArray());
|
||||
template = namedTemplateFactory.Create(name);
|
||||
}
|
||||
|
||||
if (request.Type is Type type)
|
||||
{
|
||||
content = typedDataTemplateFactory.Create(type, parameters.ToArray());
|
||||
template = templateFactory.Create(content);
|
||||
}
|
||||
|
||||
if (template is not null)
|
||||
{
|
||||
object? target = null;
|
||||
if (descriptors.FirstOrDefault(x => request.Route is string { } name && name == x.Name) is NavigationRouteDescriptor descriptor)
|
||||
{
|
||||
target = descriptor.Route;
|
||||
keyedParameters.Add(keyed.Key, keyed.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = template;
|
||||
parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hasNavigated = false;
|
||||
if (target is Frame frame)
|
||||
{
|
||||
hasNavigated = await mediator.Send(new FrameNavigation(frame, content, template, keyedParameters));
|
||||
}
|
||||
if (request.Name is { Length: > 0 } name)
|
||||
{
|
||||
content = namedDataTemplateFactory.Create(name, parameters.ToArray());
|
||||
template = namedTemplateFactory.Create(name);
|
||||
}
|
||||
|
||||
if (target is ContentDialog dialog)
|
||||
{
|
||||
hasNavigated = await mediator.Send(new ContentDialogNavigation(dialog, content, template, keyedParameters));
|
||||
}
|
||||
if (request.Type is Type type)
|
||||
{
|
||||
content = typedDataTemplateFactory.Create(type, parameters.ToArray());
|
||||
template = templateFactory.Create(content);
|
||||
}
|
||||
|
||||
if (target is ContentControl contentControl)
|
||||
{
|
||||
hasNavigated = await mediator.Send(new ContentControlNavigation(contentControl, content, template, keyedParameters));
|
||||
}
|
||||
|
||||
if (hasNavigated)
|
||||
{
|
||||
if (content is INavigated navigated)
|
||||
{
|
||||
await navigated.Navigated();
|
||||
}
|
||||
}
|
||||
if (template is not null)
|
||||
{
|
||||
object? target = null;
|
||||
if (descriptors.FirstOrDefault(x => request.Route is string { } name && name == x.Name) is NavigationRouteDescriptor descriptor)
|
||||
{
|
||||
target = descriptor.Route;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => request.Route is string { } name && name == x.Name) is NavigationRouteDescriptor descriptor)
|
||||
{
|
||||
if (descriptor.Route is ContentControl contentControl)
|
||||
{
|
||||
contentControl.Content = null;
|
||||
}
|
||||
}
|
||||
target = template;
|
||||
}
|
||||
|
||||
return default;
|
||||
bool hasNavigated = false;
|
||||
if (target is Frame frame)
|
||||
{
|
||||
hasNavigated = await mediator.Send(new FrameNavigation(frame, content, template, keyedParameters));
|
||||
}
|
||||
|
||||
if (target is ContentDialog dialog)
|
||||
{
|
||||
hasNavigated = await mediator.Send(new ContentDialogNavigation(dialog, content, template, keyedParameters));
|
||||
}
|
||||
|
||||
if (target is ContentControl contentControl)
|
||||
{
|
||||
hasNavigated = await mediator.Send(new ContentControlNavigation(contentControl, content, template, keyedParameters));
|
||||
}
|
||||
|
||||
if (hasNavigated)
|
||||
{
|
||||
if (content is INavigated navigated)
|
||||
{
|
||||
await navigated.Navigated();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => request.Route is string { } name && name == x.Name) is NavigationRouteDescriptor descriptor)
|
||||
{
|
||||
if (descriptor.Route is ContentControl contentControl)
|
||||
{
|
||||
contentControl.Content = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,26 @@
|
||||
using Avalonia.Controls.Primitives;
|
||||
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 Navigation(TRoute route,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>? parameters)
|
||||
{
|
||||
public TRoute Route { get; }
|
||||
|
||||
public Navigation(TRoute route,
|
||||
object? content,
|
||||
object? template,
|
||||
IDictionary<string, object>? parameters)
|
||||
{
|
||||
Route = route;
|
||||
Content = content;
|
||||
Template = template;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public object? Content { get; }
|
||||
|
||||
public object? Template { get; }
|
||||
|
||||
public IDictionary<string, object>? Parameters { get; }
|
||||
Route = route;
|
||||
Content = content;
|
||||
Template = template;
|
||||
Parameters = parameters;
|
||||
}
|
||||
}
|
||||
|
||||
public object? Content { get; }
|
||||
|
||||
public object? Template { get; }
|
||||
|
||||
public IDictionary<string, object>? Parameters { get; }
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
{
|
||||
internal class NavigationPageFactory : INavigationPageFactory
|
||||
{
|
||||
public IControl? GetPage(Type srcType)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
namespace Toolkit.Foundation.Avalonia;
|
||||
|
||||
public IControl GetPageFromObject(object target)
|
||||
{
|
||||
return (IControl)target;
|
||||
}
|
||||
internal class NavigationPageFactory : INavigationPageFactory
|
||||
{
|
||||
public IControl? GetPage(Type srcType)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
public IControl GetPageFromObject(object target)
|
||||
{
|
||||
return (IControl)target;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Interactivity;
|
||||
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;
|
||||
|
||||
public NavigationRouteHandler(INavigationRouteDescriptorCollection descriptors)
|
||||
{
|
||||
private readonly INavigationRouteDescriptorCollection descriptors;
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public NavigationRouteHandler(INavigationRouteDescriptorCollection descriptors)
|
||||
public ValueTask<Unit> Handle(NavigationRoute request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Route is TemplatedControl control)
|
||||
{
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public ValueTask<Unit> Handle(NavigationRoute request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Route is TemplatedControl control)
|
||||
void HandleUnloaded(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
void HandleUnloaded(object? sender, RoutedEventArgs args)
|
||||
if (descriptors.FirstOrDefault(x => x.Route == sender) is INavigationRouteDescriptor descriptor)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.Route == sender) is INavigationRouteDescriptor descriptor)
|
||||
{
|
||||
descriptors.Remove(descriptor);
|
||||
}
|
||||
descriptors.Remove(descriptor);
|
||||
}
|
||||
control.Unloaded += HandleUnloaded;
|
||||
}
|
||||
|
||||
if (descriptors.FirstOrDefault(x => x.Name == request.Name) is INavigationRouteDescriptor descriptor)
|
||||
{
|
||||
descriptors.Remove(descriptor);
|
||||
}
|
||||
|
||||
descriptors.Add(new NavigationRouteDescriptor(request.Name, request.Route));
|
||||
return default;
|
||||
control.Unloaded += HandleUnloaded;
|
||||
}
|
||||
|
||||
if (descriptors.FirstOrDefault(x => x.Name == request.Name) is INavigationRouteDescriptor descriptor)
|
||||
{
|
||||
descriptors.Remove(descriptor);
|
||||
}
|
||||
|
||||
descriptors.Add(new NavigationRouteDescriptor(request.Name, request.Route));
|
||||
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
|
||||
{
|
||||
@@ -34,4 +35,4 @@ namespace Toolkit.Foundation.Avalonia
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class ConfigurationInitializer<TConfiguration> : IInitializable where TConfiguration : class, new()
|
||||
{
|
||||
@@ -19,4 +19,4 @@ public class ConfigurationInitializer<TConfiguration> : IInitializable where TCo
|
||||
await mediator.Send(configuration);
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class ConfigurationWriter<TConfiguration> : IConfigurationWriter<TConfiguration> where TConfiguration : class, new()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public interface IConfigurationWriter<TConfiguration> where TConfiguration : class
|
||||
{
|
||||
void Write(string section, TConfiguration args);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public interface IWritableConfigurationProvider
|
||||
{
|
||||
void Write<TValue>(string section, TValue value) where TValue : class, new();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public interface IWritableJsonConfigurationBuilder
|
||||
{
|
||||
@@ -9,4 +9,4 @@ public interface IWritableJsonConfigurationBuilder
|
||||
IWritableJsonConfigurationBuilder AddDefaultFileStream(Stream stream);
|
||||
|
||||
void Build(string path);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public interface IWritableJsonConfigurationDescriptor
|
||||
{
|
||||
Type ConfigurationType { get; }
|
||||
|
||||
string Key { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
using Json.Patch;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class WritableJsonConfigurationBuilder : IWritableJsonConfigurationBuilder
|
||||
{
|
||||
@@ -105,4 +102,4 @@ public class WritableJsonConfigurationBuilder : IWritableJsonConfigurationBuilde
|
||||
content = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.FileProviders;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public static class WritableJsonConfigurationExtensions
|
||||
{
|
||||
@@ -71,4 +71,4 @@ public static class WritableJsonConfigurationExtensions
|
||||
}
|
||||
|
||||
public static IConfigurationBuilder AddWritableJsonFile(this IConfigurationBuilder builder, Action<WritableJsonConfigurationSource> configureSource) => builder.Add(configureSource);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
internal class WritableJsonConfigurationFile
|
||||
{
|
||||
@@ -145,4 +145,4 @@ internal class WritableJsonConfigurationFile
|
||||
throw new FormatException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,12 @@ using Microsoft.Extensions.FileProviders;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class WritableJsonConfigurationProvider : JsonConfigurationProvider, IWritableConfigurationProvider
|
||||
{
|
||||
public WritableJsonConfigurationProvider(JsonConfigurationSource source) : base(source)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Write<TValue>(string section, TValue value) where TValue : class, new()
|
||||
@@ -43,4 +42,4 @@ public class WritableJsonConfigurationProvider : JsonConfigurationProvider, IWri
|
||||
document.WriteTo(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class WritableJsonConfigurationSource : JsonConfigurationSource
|
||||
{
|
||||
@@ -24,4 +24,4 @@ public class WritableJsonConfigurationSource : JsonConfigurationSource
|
||||
Factory?.Build(outputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
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;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class WriteHandler<TConfiguration> : IRequestHandler<Write<TConfiguration>> where TConfiguration : class
|
||||
{
|
||||
@@ -26,4 +26,4 @@ public class WriteHandler<TConfiguration> : IRequestHandler<Write<TConfiguration
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public static class IHostBuilderExtensions
|
||||
{
|
||||
@@ -13,4 +13,4 @@ public static class IHostBuilderExtensions
|
||||
|
||||
return hostBuilder.UseContentRoot(contentRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
@@ -11,7 +11,6 @@ public static class IServiceCollectionExtensions
|
||||
return serviceCollection;
|
||||
}
|
||||
|
||||
|
||||
public static IServiceCollection AddFoundation(this IServiceCollection serviceCollection)
|
||||
{
|
||||
serviceCollection.AddSingleton<IServiceFactory>(provider => new ServiceFactory(provider.GetService, (instanceType, parameters) => ActivatorUtilities.CreateInstance(provider, instanceType, parameters!)))
|
||||
@@ -27,4 +26,4 @@ public static class IServiceCollectionExtensions
|
||||
|
||||
return serviceCollection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public static class IServiceFactoryExtensions
|
||||
{
|
||||
@@ -12,4 +12,4 @@ public static class IServiceFactoryExtensions
|
||||
ServiceFactoryDescriptor? descriptor = new(serviceFactory);
|
||||
return descriptor.Create(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class AppService : IHostedService
|
||||
{
|
||||
@@ -22,4 +22,4 @@ public class AppService : IHostedService
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public interface ICache
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public interface IInitializable
|
||||
{
|
||||
Task InitializeAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public interface IInitialization
|
||||
{
|
||||
Task InitializeAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class Initialization : IInitialization
|
||||
{
|
||||
@@ -23,4 +23,4 @@ public class Initialization : IInitialization
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Mediator;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public record Initialize : IRequest;
|
||||
public record Initialize : IRequest;
|
||||
@@ -1,6 +1,6 @@
|
||||
using Mediator;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class InitializeHandler : IRequestHandler<Initialize>
|
||||
{
|
||||
@@ -16,4 +16,4 @@ public class InitializeHandler : IRequestHandler<Initialize>
|
||||
await initialization.InitializeAsync();
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
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;
|
||||
using System.Collections.Generic;
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
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
|
||||
{
|
||||
public interface INavigationConfirmation
|
||||
{
|
||||
ValueTask<bool> CanConfirm();
|
||||
}
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface INavigated
|
||||
{
|
||||
ValueTask Navigated();
|
||||
}
|
||||
public interface INavigationConfirmation
|
||||
{
|
||||
ValueTask<bool> CanConfirm();
|
||||
}
|
||||
|
||||
public interface INavigated
|
||||
{
|
||||
ValueTask Navigated();
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface INavigationRouteDescriptor
|
||||
{
|
||||
object Route { get; }
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
string? Name { get; }
|
||||
}
|
||||
public interface INavigationRouteDescriptor
|
||||
{
|
||||
object Route { 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
|
||||
{
|
||||
public interface IParameter
|
||||
{
|
||||
string? Key { get; }
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
KeyValuePair<string, object>? GetValue(object target);
|
||||
}
|
||||
public interface IParameter
|
||||
{
|
||||
string? Key { get; }
|
||||
|
||||
KeyValuePair<string, object>? GetValue(object target);
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
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;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public Navigate(Type type, params object?[] parameters)
|
||||
{
|
||||
Type = type;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public Type? Type { get; }
|
||||
|
||||
public object? Route { get; init; }
|
||||
|
||||
public string? Name { get; }
|
||||
|
||||
public string? FriendlyName { get; init; }
|
||||
|
||||
public object?[] Parameters { get; }
|
||||
Name = name;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public Navigate(Type type, params object?[] parameters)
|
||||
{
|
||||
Type = type;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
public Type? Type { get; }
|
||||
|
||||
public object? Route { get; init; }
|
||||
|
||||
public string? Name { get; }
|
||||
|
||||
public string? FriendlyName { get; init; }
|
||||
|
||||
public object?[] Parameters { get; }
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using Mediator;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public record NavigateBack(object Route) : IRequest;
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
}
|
||||
public record NavigateBack(object Route) : IRequest;
|
||||
@@ -1,6 +1,5 @@
|
||||
using Mediator;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public record NavigationRoute(string Name, object Route) : IRequest;
|
||||
}
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public record NavigationRoute(string Name, object Route) : IRequest;
|
||||
@@ -1,15 +1,14 @@
|
||||
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;
|
||||
Route = route;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public object Route { get; }
|
||||
Name = name;
|
||||
Route = route;
|
||||
}
|
||||
|
||||
public string Name { 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
|
||||
{
|
||||
public interface IServiceFactory
|
||||
{
|
||||
object? Create(Type type, params object?[] parameters);
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
T? Create<T>(Type type, params object?[] parameters);
|
||||
}
|
||||
}
|
||||
public interface IServiceFactory
|
||||
{
|
||||
object? Create(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,26 +1,25 @@
|
||||
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?[], object> creator;
|
||||
|
||||
public ServiceFactory(Func<Type, object?> factory, Func<Type, object?[], object> creator)
|
||||
{
|
||||
private readonly Func<Type, object?> factory;
|
||||
private readonly Func<Type, object?[], object> creator;
|
||||
|
||||
public ServiceFactory(Func<Type, object?> factory, Func<Type, object?[], object> creator)
|
||||
{
|
||||
this.factory = factory;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public object? Create(Type type, params object?[] parameters)
|
||||
{
|
||||
dynamic? lookup = factory(typeof(IServiceCreator<>).MakeGenericType(type));
|
||||
return lookup is not null ? lookup.Create(creator, parameters) : creator(type, parameters);
|
||||
}
|
||||
|
||||
public T? Create<T>(Type type, params object?[] parameters)
|
||||
{
|
||||
dynamic? lookup = factory(typeof(IServiceCreator<>).MakeGenericType(type));
|
||||
return lookup is not null ? (T)lookup.Create(creator, parameters) : (T)creator(type, parameters);
|
||||
}
|
||||
this.factory = factory;
|
||||
this.creator = creator;
|
||||
}
|
||||
}
|
||||
|
||||
public object? Create(Type type, params object?[] parameters)
|
||||
{
|
||||
dynamic? lookup = factory(typeof(IServiceCreator<>).MakeGenericType(type));
|
||||
return lookup is not null ? lookup.Create(creator, parameters) : creator(type, parameters);
|
||||
}
|
||||
|
||||
public T? Create<T>(Type type, params object?[] parameters)
|
||||
{
|
||||
dynamic? lookup = factory(typeof(IServiceCreator<>).MakeGenericType(type));
|
||||
return lookup is not null ? (T)lookup.Create(creator, parameters) : (T)creator(type, parameters);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,24 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
internal class ServiceFactoryDescriptor
|
||||
{
|
||||
internal class ServiceFactoryDescriptor
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public ServiceFactoryDescriptor(IServiceFactory serviceFactory)
|
||||
{
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public ServiceFactoryDescriptor(IServiceFactory serviceFactory)
|
||||
{
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
public object? Create(Type type)
|
||||
{
|
||||
MethodInfo? methodInfo = typeof(ServiceFactoryDescriptor).GetMethod(nameof(Create), BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
return methodInfo?.MakeGenericMethod(type).Invoke(this, new object[] { type });
|
||||
}
|
||||
|
||||
private T Create<T>(Type type)
|
||||
{
|
||||
return serviceFactory.Create<T>(type);
|
||||
}
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
}
|
||||
|
||||
public object? Create(Type type)
|
||||
{
|
||||
MethodInfo? methodInfo = typeof(ServiceFactoryDescriptor).GetMethod(nameof(Create), BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
return methodInfo?.MakeGenericMethod(type).Invoke(this, new object[] { type });
|
||||
}
|
||||
|
||||
private T? Create<T>(Type 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;
|
||||
|
||||
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,15 +1,14 @@
|
||||
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; }
|
||||
|
||||
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
|
||||
{
|
||||
ITemplateDescriptor? Get(string name);
|
||||
|
||||
public interface ITemplateDescriptorProvider
|
||||
{
|
||||
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;
|
||||
|
||||
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,36 +1,35 @@
|
||||
namespace Toolkit.Foundation
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class NamedDataTemplateFactory : INamedDataTemplateFactory
|
||||
{
|
||||
public class NamedDataTemplateFactory : INamedDataTemplateFactory
|
||||
private readonly Dictionary<string, object> cache = new();
|
||||
|
||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public NamedDataTemplateFactory(IReadOnlyCollection<ITemplateDescriptor> descriptors,
|
||||
IServiceFactory serviceFactory)
|
||||
{
|
||||
private readonly Dictionary<string, object> cache = new();
|
||||
this.descriptors = descriptors;
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public NamedDataTemplateFactory(IReadOnlyCollection<ITemplateDescriptor> descriptors,
|
||||
IServiceFactory serviceFactory)
|
||||
public virtual object? Create(string name, params object[] parameters)
|
||||
{
|
||||
if (cache.TryGetValue(name, out object? data))
|
||||
{
|
||||
this.descriptors = descriptors;
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
public virtual object? Create(string name, params object[] parameters)
|
||||
{
|
||||
if (cache.TryGetValue(name, out object? data))
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
if (descriptors.FirstOrDefault(x => x.Name == name) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
data = parameters is { Length: > 0 } ? serviceFactory.Create<object>(descriptor.ContentType, parameters) : serviceFactory.Create(descriptor.ContentType);
|
||||
if (data is ICache cache)
|
||||
{
|
||||
this.cache[name] = cache;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
if (descriptors.FirstOrDefault(x => x.Name == name) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
data = parameters is { Length: > 0 } ? serviceFactory.Create<object>(descriptor.ContentType, parameters) : serviceFactory.Create(descriptor.ContentType);
|
||||
if (data is ICache cache)
|
||||
{
|
||||
this.cache[name] = cache;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,40 @@
|
||||
namespace Toolkit.Foundation
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class NamedTemplateFactory : INamedTemplateFactory
|
||||
{
|
||||
public class NamedTemplateFactory : INamedTemplateFactory
|
||||
private readonly Dictionary<string, object> cache = new();
|
||||
|
||||
private readonly ITemplateDescriptorProvider provider;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public NamedTemplateFactory(ITemplateDescriptorProvider provider,
|
||||
IServiceFactory serviceFactory)
|
||||
{
|
||||
private readonly Dictionary<string, object> cache = new();
|
||||
this.provider = provider;
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
private readonly ITemplateDescriptorProvider provider;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public NamedTemplateFactory(ITemplateDescriptorProvider provider,
|
||||
IServiceFactory serviceFactory)
|
||||
public virtual object? Create(string name)
|
||||
{
|
||||
if (cache.TryGetValue(name, out object? view))
|
||||
{
|
||||
this.provider = provider;
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
public virtual object? Create(string name)
|
||||
{
|
||||
if (cache.TryGetValue(name, out object? view))
|
||||
{
|
||||
return view;
|
||||
}
|
||||
|
||||
if (provider.Get(name) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
view = serviceFactory.Create(descriptor.TemplateType);
|
||||
if (view is ICache cache)
|
||||
{
|
||||
this.cache[name] = cache;
|
||||
}
|
||||
|
||||
if (descriptor.GetType().GenericTypeArguments is { Length: 2 })
|
||||
{
|
||||
(descriptor as dynamic).ViewInvoker?.Invoke(view);
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
if (provider.Get(name) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
view = serviceFactory.Create(descriptor.TemplateType);
|
||||
if (view is ICache cache)
|
||||
{
|
||||
this.cache[name] = cache;
|
||||
}
|
||||
|
||||
if (descriptor.GetType().GenericTypeArguments is { Length: 2 })
|
||||
{
|
||||
(descriptor as dynamic).ViewInvoker?.Invoke(view);
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
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();
|
||||
|
||||
public IReadOnlyCollection<ITemplateDescriptor> Descriptors => new ReadOnlyCollection<ITemplateDescriptor>(descriptors);
|
||||
|
||||
public ITemplateBuilder Add<TViewModel, TView>(string name, ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||
{
|
||||
private readonly List<ITemplateDescriptor> descriptors = new();
|
||||
|
||||
public IReadOnlyCollection<ITemplateDescriptor> Descriptors => new ReadOnlyCollection<ITemplateDescriptor>(descriptors);
|
||||
|
||||
public ITemplateBuilder Add<TViewModel, TView>(string name, ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||
{
|
||||
descriptors.Add(new TemplateDescriptor(typeof(TViewModel), typeof(TView), name, lifetime));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ITemplateBuilder Add<TViewModel, TView>(ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||
{
|
||||
descriptors.Add(new TemplateDescriptor(typeof(TViewModel), typeof(TView), null, lifetime));
|
||||
return this;
|
||||
}
|
||||
descriptors.Add(new TemplateDescriptor(typeof(TViewModel), typeof(TView), name, lifetime));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public ITemplateBuilder Add<TViewModel, TView>(ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||
{
|
||||
descriptors.Add(new TemplateDescriptor(typeof(TViewModel), typeof(TView), null, lifetime));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,25 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class TemplateDescriptor : ITemplateDescriptor
|
||||
{
|
||||
public class TemplateDescriptor : ITemplateDescriptor
|
||||
public TemplateDescriptor(Type dataType,
|
||||
Type templateType,
|
||||
string? name = null,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||
{
|
||||
public TemplateDescriptor(Type dataType,
|
||||
Type templateType,
|
||||
string? name = null,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||
{
|
||||
TemplateType = templateType;
|
||||
ContentType = dataType;
|
||||
Name = name;
|
||||
Lifetime = lifetime;
|
||||
}
|
||||
|
||||
public ServiceLifetime Lifetime { get; }
|
||||
|
||||
public Type TemplateType { get; }
|
||||
|
||||
public Type ContentType { get; }
|
||||
|
||||
public string? Name { get; }
|
||||
TemplateType = templateType;
|
||||
ContentType = dataType;
|
||||
Name = name;
|
||||
Lifetime = lifetime;
|
||||
}
|
||||
}
|
||||
|
||||
public ServiceLifetime Lifetime { get; }
|
||||
|
||||
public Type TemplateType { get; }
|
||||
|
||||
public Type ContentType { get; }
|
||||
|
||||
public string? Name { get; }
|
||||
}
|
||||
@@ -1,42 +1,41 @@
|
||||
namespace Toolkit.Foundation
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class TemplateDescriptorProvider : ITemplateDescriptorProvider
|
||||
{
|
||||
public class TemplateDescriptorProvider : ITemplateDescriptorProvider
|
||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||
|
||||
public TemplateDescriptorProvider(IReadOnlyCollection<ITemplateDescriptor> descriptors)
|
||||
{
|
||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||
|
||||
public TemplateDescriptorProvider(IReadOnlyCollection<ITemplateDescriptor> descriptors)
|
||||
{
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
|
||||
public ITemplateDescriptor? Get(string name)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.Name == name) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ITemplateDescriptor? Get(Type type)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.ContentType == type) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ITemplateDescriptor? Get<T>()
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.ContentType == typeof(T)) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
this.descriptors = descriptors;
|
||||
}
|
||||
}
|
||||
|
||||
public ITemplateDescriptor? Get(string name)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.Name == name) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ITemplateDescriptor? Get(Type type)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.ContentType == type) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ITemplateDescriptor? Get<T>()
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.ContentType == typeof(T)) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,42 @@
|
||||
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 ITemplateDescriptorProvider provider;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public TemplateFactory(ITemplateDescriptorProvider provider,
|
||||
IServiceFactory serviceFactory)
|
||||
{
|
||||
private readonly Dictionary<object, object> cache = new();
|
||||
this.provider = provider;
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
private readonly ITemplateDescriptorProvider provider;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public TemplateFactory(ITemplateDescriptorProvider provider,
|
||||
IServiceFactory serviceFactory)
|
||||
public virtual object? Create([MaybeNull] object? data)
|
||||
{
|
||||
if (data is null)
|
||||
{
|
||||
this.provider = provider;
|
||||
this.serviceFactory = serviceFactory;
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual object? Create([MaybeNull] object? data)
|
||||
if (cache.TryGetValue(data, out object? template))
|
||||
{
|
||||
if (data is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cache.TryGetValue(data, out object? template))
|
||||
{
|
||||
return template;
|
||||
}
|
||||
|
||||
if (provider.Get(data.GetType()) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
template = serviceFactory.Create(descriptor.TemplateType);
|
||||
if (template is ICache cache)
|
||||
{
|
||||
this.cache[data] = cache;
|
||||
}
|
||||
}
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
if (provider.Get(data.GetType()) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
template = serviceFactory.Create(descriptor.TemplateType);
|
||||
if (template is ICache cache)
|
||||
{
|
||||
this.cache[data] = cache;
|
||||
}
|
||||
}
|
||||
|
||||
return template;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,35 @@
|
||||
namespace Toolkit.Foundation
|
||||
namespace Toolkit.Framework.Foundation;
|
||||
|
||||
public class TypedDataTemplateFactory : ITypedDataTemplateFactory
|
||||
{
|
||||
public class TypedDataTemplateFactory : ITypedDataTemplateFactory
|
||||
private readonly Dictionary<Type, object> cache = new();
|
||||
|
||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public TypedDataTemplateFactory(IReadOnlyCollection<ITemplateDescriptor> descriptors,
|
||||
IServiceFactory serviceFactory)
|
||||
{
|
||||
private readonly Dictionary<Type, object> cache = new();
|
||||
this.descriptors = descriptors;
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
private readonly IReadOnlyCollection<ITemplateDescriptor> descriptors;
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
|
||||
public TypedDataTemplateFactory(IReadOnlyCollection<ITemplateDescriptor> descriptors,
|
||||
IServiceFactory serviceFactory)
|
||||
public virtual object? Create(Type type, params object[] parameters)
|
||||
{
|
||||
if (cache.TryGetValue(type, out object? data))
|
||||
{
|
||||
this.descriptors = descriptors;
|
||||
this.serviceFactory = serviceFactory;
|
||||
}
|
||||
|
||||
public virtual object? Create(Type type, params object[] parameters)
|
||||
{
|
||||
if (cache.TryGetValue(type, out object? data))
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
if (descriptors.FirstOrDefault(x => x.ContentType == type) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
data = parameters is { Length: > 0 } ? serviceFactory.Create<object>(descriptor.ContentType, parameters) : serviceFactory.Create(descriptor.ContentType);
|
||||
if (data is ICache cache)
|
||||
{
|
||||
this.cache[type] = cache;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
if (descriptors.FirstOrDefault(x => x.ContentType == type) is ITemplateDescriptor descriptor)
|
||||
{
|
||||
data = parameters is { Length: > 0 } ? serviceFactory.Create<object>(descriptor.ContentType, parameters) : serviceFactory.Create(descriptor.ContentType);
|
||||
if (data is ICache cache)
|
||||
{
|
||||
this.cache[type] = cache;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user