mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-23 06:25:45 +00:00
use compiled bidning for localizations (#5684)
This commit is contained in:
parent
9f26fd3600
commit
d6bc0de785
1 changed files with 16 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
using Avalonia.Data;
|
using Avalonia.Data.Core;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.Markup.Xaml.MarkupExtensions;
|
using Avalonia.Markup.Xaml.MarkupExtensions;
|
||||||
|
using Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Common.Locale
|
namespace Ryujinx.Ava.Common.Locale
|
||||||
|
@ -18,11 +19,20 @@ namespace Ryujinx.Ava.Common.Locale
|
||||||
{
|
{
|
||||||
LocaleKeys keyToUse = Key;
|
LocaleKeys keyToUse = Key;
|
||||||
|
|
||||||
ReflectionBindingExtension binding = new($"[{keyToUse}]")
|
var builder = new CompiledBindingPathBuilder();
|
||||||
|
|
||||||
|
builder.SetRawSource(LocaleManager.Instance)
|
||||||
|
.Property(new ClrPropertyInfo("Item",
|
||||||
|
obj => (LocaleManager.Instance[keyToUse]),
|
||||||
|
null,
|
||||||
|
typeof(string)), (weakRef, iPropInfo) =>
|
||||||
{
|
{
|
||||||
Mode = BindingMode.OneWay,
|
return PropertyInfoAccessorFactory.CreateInpcPropertyAccessor(weakRef, iPropInfo);
|
||||||
Source = LocaleManager.Instance,
|
});
|
||||||
};
|
|
||||||
|
var path = builder.Build();
|
||||||
|
|
||||||
|
var binding = new CompiledBindingExtension(path);
|
||||||
|
|
||||||
return binding.ProvideValue(serviceProvider);
|
return binding.ProvideValue(serviceProvider);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue