mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-26 03:59:34 +08:00
update version s
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
using System.Application.UI.Resx;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 本地化、多语言视图模型
|
||||
/// </summary>
|
||||
[Obsolete("Languages")]
|
||||
public interface ILocalizationViewModel
|
||||
{
|
||||
public void OnChangeLanguage()
|
||||
{
|
||||
var properties = GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
var query = from p in properties
|
||||
let attr = p.GetCustomAttribute<ResStringAttribute>()
|
||||
where p.PropertyType == typeof(string) && attr != null
|
||||
select (p, attr.ResId);
|
||||
foreach (var (p, ResId) in query)
|
||||
{
|
||||
var resId = ResId ?? p.Name;
|
||||
var value = AppResources.ResourceManager.GetString(resId);
|
||||
p.SetValue(this, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
[Obsolete("Languages")]
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public sealed class ResStringAttribute : Attribute
|
||||
{
|
||||
public string? ResId { get; }
|
||||
|
||||
public ResStringAttribute(string? resId = null)
|
||||
{
|
||||
ResId = resId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,25 +3,19 @@ using System.Application.Mvvm;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class ViewModelBase : ReactiveObject, IDisposable, ILocalizationViewModel
|
||||
public class ViewModelBase : ReactiveObject, IDisposable
|
||||
{
|
||||
[NonSerialized] CompositeDisposable? _compositeDisposable;
|
||||
|
||||
[NonSerialized] bool _disposed;
|
||||
|
||||
public ViewModelBase()
|
||||
{
|
||||
ILocalizationViewModel localization = this;
|
||||
localization.OnChangeLanguage();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否在设计器的上下文中运行
|
||||
/// </summary>
|
||||
public static bool IsInDesignMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 释放该实例使用的所有资源
|
||||
/// 释放该实例使用的所有资源
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user