sourcegit/src/Converters/ListConverters.cs
leo 5d2a442144
code_review: PR #515
* remove Linq expressions due to AOT limitations. See https://learn.microsoft.com/zh-cn/dotnet/core/deploying/native-aot/?tabs=windows%2Cnet8#limitations-of-native-aot-deployment
* rename `FilteredLocks` to `VisibleLocks`
* use `Commands.Config.Get` instead of `Commands.Config.ListAll`
* disable checkbox if user name is not valid
2024-09-26 15:36:20 +08:00

25 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Avalonia.Data.Converters;
namespace SourceGit.Converters
{
public static class ListConverters
{
public static readonly FuncValueConverter<IList, string> ToCount =
new FuncValueConverter<IList, string>(v => v == null ? " (0)" : $" ({v.Count})");
public static readonly FuncValueConverter<IList, bool> IsNullOrEmpty =
new FuncValueConverter<IList, bool>(v => v == null || v.Count == 0);
public static readonly FuncValueConverter<IList, bool> IsNotNullOrEmpty =
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 0);
public static readonly FuncValueConverter<List<Models.Change>, List<Models.Change>> Top100Changes =
new FuncValueConverter<List<Models.Change>, List<Models.Change>>(v => (v == null || v.Count < 100) ? v : v.GetRange(0, 100));
public static readonly FuncValueConverter<IList, bool> IsOnlyTop100Shows =
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 100);
}
}