Skip to content

Commit b0c2b33

Browse files
author
Sébastien Geiser
committed
Add StringEqualsConverter and some refactoring
1 parent 350087f commit b0c2b33

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

CodingSeb.Converters/CodingSeb.Converters.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
1010
<Copyright>Copyright © Coding Seb 2019</Copyright>
1111
<PackageProjectUrl>https://github.com/codingseb/Converters</PackageProjectUrl>
12+
<Authors>CodingSeb</Authors>
1213
</PropertyGroup>
1314

1415
<ItemGroup>

CodingSeb.Converters/Converters/StringContainsConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class StringContainsConverter : BaseConverter, IValueConverter
1919
/// <summary>
2020
/// The string to search
2121
/// </summary>
22-
public string ContainsString { get; set; } = "";
22+
public string ContainsString { get; set; } = string.Empty;
2323

2424
/// <summary>
2525
/// if <c>true</c>, ignore case of the string to find ContainsString, if <c>false</c> take care of the case. By default : false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Globalization;
4+
using System.Windows;
5+
using System.Windows.Data;
6+
7+
namespace CodingSeb.Converters.Converters
8+
{
9+
/// <summary>
10+
/// This Converter return <c>true</c> if binding string Equals Value, <c>false</c> otherwise.
11+
/// This converter has no ConvertBack. It is only usable source -> to target.
12+
/// </summary>
13+
public class StringEqualsConverter : BaseConverter, IValueConverter
14+
{
15+
public bool? InDesigner { get; set; }
16+
17+
/// <summary>
18+
/// The string to test equality
19+
/// </summary>
20+
public string Value { get; set; } = string.Empty;
21+
22+
/// <summary>
23+
/// To specify the culture and case of the equals
24+
/// </summary>
25+
public StringComparison StringComparison { get; set; }
26+
27+
/// <summary>
28+
/// Do the conversion here
29+
/// </summary>
30+
/// <param name="value">the input value</param>
31+
/// <param name="targetType"></param>
32+
/// <param name="parameter"></param>
33+
/// <param name="culture"></param>
34+
/// <returns>the converted value</returns>
35+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
36+
{
37+
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()) && InDesigner != null) return InDesigner.Value;
38+
39+
return value.ToString().Equals(Value, StringComparison);
40+
}
41+
42+
/// <summary>
43+
/// No Convert back
44+
/// </summary>
45+
/// <param name="value"></param>
46+
/// <param name="targetType"></param>
47+
/// <param name="parameter"></param>
48+
/// <param name="culture"></param>
49+
/// <returns></returns>
50+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
51+
{
52+
throw new NotImplementedException();
53+
}
54+
}
55+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.BoolMultiBindingAndConditionConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
7+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.BoolMultiBindingOrConditionConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
8+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.CollectionCountOrArrayLengthConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
9+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.Converters.StringEqualsConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
10+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.DoubleAbsoluteValueConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
11+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.DoubleMaxValueMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
12+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.DoubleMinValueMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
13+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.DoubleValuesMultiplyMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
14+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.DoubleValuesSumMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
15+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.GetTypeConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
16+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.RegexIsMatchConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
17+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.RegexIsMatchMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
18+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.RegexMatchValueConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
19+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.RegexMatchValueMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
20+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.RegexReplaceConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
21+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.RegexReplaceMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
22+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.StringContainsConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
23+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.StringContainsMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
24+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.StringFormatConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]
25+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.StringFormatMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
26+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.StringReplaceMultiBindingConverter.ConvertBack(System.Object,System.Type[],System.Object,System.Globalization.CultureInfo)~System.Object[]")]
27+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("General", "RCS1079:Throwing of new NotImplementedException.", Justification = "<Pending>", Scope = "member", Target = "~M:CodingSeb.Converters.TypeCheckingConverter.ConvertBack(System.Object,System.Type,System.Object,System.Globalization.CultureInfo)~System.Object")]

0 commit comments

Comments
 (0)