first commit

This commit is contained in:
2025-07-06 00:23:46 +02:00
commit 38f50c8819
1788 changed files with 112878 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
namespace Nitrox.Launcher.Models.Converters;
public class ToIntConverter : Converter<ToIntConverter>
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
return value switch
{
int i => i,
string valueStr when int.TryParse(valueStr, out int result) => result,
ICollection list => list.Count,
IEnumerable enumerable => enumerable.Cast<object>().Count(),
_ => System.Convert.ToInt32(value)
};
}
catch
{
return 0;
}
}
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => value;
}