sourcegit/src/Converters/ListConverters.cs
leo 53c6fc8999
fix: remove binding error in debug mode (#1338)
Signed-off-by: leo <longshuang@msn.cn>
2025-05-20 21:44:28 +08:00

28 lines
1.2 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> Count =
new FuncValueConverter<IList, string>(v => v == null ? "0" : $"{v.Count}");
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);
}
}