Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
StringNotEqualsConverter.cs
1using System;
2using System.Globalization;
3using Microsoft.Maui.Controls;
4
6{
11 public class StringNotEqualsConverter : IValueConverter
12 {
13 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 {
15 if (parameter is null)
16 return true; // no parameter -> always true (not equal by definition)
17
18 string? input = value?.ToString();
19 string paramRaw = parameter.ToString() ?? string.Empty;
20 bool ignoreCase = false;
21
22 // Allow syntax: "Value|ignorecase"
23 int pipe = paramRaw.IndexOf('|');
24 if (pipe >= 0)
25 {
26 string flags = paramRaw[(pipe + 1)..];
27 paramRaw = paramRaw[..pipe];
28 ignoreCase = flags.Contains("ignorecase", StringComparison.OrdinalIgnoreCase);
29 }
30
31 StringComparison cmp = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
32 return !string.Equals(input, paramRaw, cmp);
33 }
34
35 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException();
36 }
37}
Returns true if bound string value is NOT equal (case-sensitive by default) to ConverterParameter....