22 lines
648 B
C#
22 lines
648 B
C#
using System.Globalization;
|
|
using Avalonia.Data.Converters;
|
|
using XSDVisualiser.Core;
|
|
|
|
namespace XSDVisualiser.Desktop.Converters;
|
|
|
|
public class CardinalityToLabelConverter : IValueConverter
|
|
{
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is not Occurs occ) return null;
|
|
|
|
var min = occ.Min;
|
|
var max = occ.MaxIsUnbounded ? "*" : occ.Max.ToString(culture);
|
|
return $"[{min}..{max}]";
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
} |