39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using ControlzEx.Standard;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Data;
|
|
|
|
namespace BDU.Converters
|
|
{
|
|
public class ParameterValueToStringConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is IEnumerable enumerable && !(value is string))
|
|
{
|
|
var elements = enumerable.Cast<object>().Select(item => item?.ToString() ?? "null");
|
|
return $"[{string.Join(", ", elements)}]";
|
|
}
|
|
else if(value != null)
|
|
{
|
|
return value.ToString()!;
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value != null)
|
|
{
|
|
return value.ToString()!;
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
}
|