|
3 | 3 |
|
4 | 4 | namespace CommunityToolkit.Maui.Converters; |
5 | 5 |
|
6 | | -/// <summary>Converts the incoming value to a <see cref="bool"/> indicating whether or not the value is within a range.</summary> |
| 6 | +/// <summary>Converts the incoming value to a <see cref="bool"/> indicating whether the value is within a range.</summary> |
7 | 7 | [AcceptEmptyServiceProvider] |
8 | 8 | public sealed partial class IsInRangeConverter : IsInRangeConverter<IComparable, object>; |
9 | 9 |
|
10 | | -/// <summary>Converts the incoming value to a <see cref="bool"/> indicating whether or not the value is within a range.</summary> |
11 | | -public abstract class IsInRangeConverter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TValue, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TReturnObject> : BaseConverterOneWay<TValue, object> where TValue : IComparable |
| 10 | +/// <summary>Converts the incoming value to a <see cref="bool"/> indicating whether the value is within a range.</summary> |
| 11 | +public abstract partial class IsInRangeConverter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TValue, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TReturnObject> : BaseConverterOneWay<TValue, object> where TValue : IComparable |
12 | 12 | { |
13 | | - /// <summary> |
14 | | - /// Bindable property for <see cref="FalseObject"/> |
15 | | - /// </summary> |
16 | | - public static readonly BindableProperty FalseObjectProperty = BindableProperty.Create(nameof(FalseObject), typeof(TReturnObject?), typeof(IsInRangeConverter<TValue, TReturnObject>)); |
17 | | - |
18 | | - /// <summary> |
19 | | - /// Bindable property for <see cref="MaxValue"/> |
20 | | - /// </summary> |
21 | | - public static readonly BindableProperty MaxValueProperty = BindableProperty.Create(nameof(MaxValue), typeof(TValue), typeof(IsInRangeConverter<TValue, TReturnObject>)); |
22 | | - |
23 | | - /// <summary> |
24 | | - /// Bindable property for <see cref="MinValue"/> |
25 | | - /// </summary> |
26 | | - public static readonly BindableProperty MinValueProperty = BindableProperty.Create(nameof(MinValue), typeof(TValue), typeof(IsInRangeConverter<TValue, TReturnObject>)); |
27 | | - |
28 | | - /// <summary> |
29 | | - /// Bindable property for <see cref="TrueObject"/> |
30 | | - /// </summary> |
31 | | - public static readonly BindableProperty TrueObjectProperty = BindableProperty.Create(nameof(TrueObject), typeof(TReturnObject?), typeof(IsInRangeConverter<TValue, TReturnObject>)); |
32 | | - |
33 | 13 | /// <inheritdoc/> |
34 | 14 | public override object DefaultConvertReturnValue { get; set; } = new(); |
35 | 15 |
|
36 | 16 | /// <summary>If supplied this value will be returned when the converter receives an input value that is <b>outside</b> the <see cref="MinValue" /> and <see cref="MaxValue" />s.</summary> |
37 | | - public TReturnObject? FalseObject |
38 | | - { |
39 | | - get => (TReturnObject?)GetValue(FalseObjectProperty); |
40 | | - set => SetValue(FalseObjectProperty, value); |
41 | | - } |
| 17 | + [BindableProperty] |
| 18 | + public partial TReturnObject? FalseObject { get; set; } |
42 | 19 |
|
43 | 20 | /// <summary>The upper bounds of the range to compare against when determining whether the input value to the convert is within range.</summary> |
44 | | - public TValue? MaxValue |
45 | | - { |
46 | | - get => (TValue?)GetValue(MaxValueProperty); |
47 | | - set => SetValue(MaxValueProperty, value); |
48 | | - } |
| 21 | + [BindableProperty] |
| 22 | + public partial TValue? MaxValue { get; set; } |
49 | 23 |
|
50 | 24 | /// <summary>The lower bounds of the range to compare against when determining whether the input value to the convert is within range.</summary> |
51 | | - public TValue? MinValue |
52 | | - { |
53 | | - get => (TValue?)GetValue(MinValueProperty); |
54 | | - set => SetValue(MinValueProperty, value); |
55 | | - } |
| 25 | + [BindableProperty] |
| 26 | + public partial TValue? MinValue { get; set; } |
56 | 27 |
|
57 | 28 | /// <summary>If supplied this value will be returned when the converter receives an input value that is <b>inside</b> (inclusive) of the <see cref="MinValue" /> and <see cref="MaxValue" />s.</summary> |
58 | | - public TReturnObject? TrueObject |
59 | | - { |
60 | | - get => (TReturnObject?)GetValue(TrueObjectProperty); |
61 | | - set => SetValue(TrueObjectProperty, value); |
62 | | - } |
| 29 | + [BindableProperty] |
| 30 | + public partial TReturnObject? TrueObject { get; set; } |
63 | 31 |
|
64 | 32 | /// <summary>Converts an object that implemented IComparable to a <see cref="bool"/> based on the object being within a <see cref="MinValue"/> and <see cref="MaxValue"/> range.</summary> |
65 | 33 | /// <param name="value">The value to convert.</param> |
|
0 commit comments