-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMultiChoiceOption.cs
More file actions
35 lines (30 loc) · 1.21 KB
/
MultiChoiceOption.cs
File metadata and controls
35 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using CommunityToolkit.Tooling.SampleGen.Metadata;
namespace CommunityToolkit.Tooling.SampleGen.Attributes;
/// <summary>
/// Holds data for a multiple choice option.
/// Primarily used by <see cref="ToolkitSampleMultiChoiceOptionMetadataViewModel"/>.
/// </summary>
/// <param name="Label">A label shown to the user for this option.</param>
/// <param name="Value">The value passed to XAML when this option is selected.</param>
public record MultiChoiceOption(string Label, object Value)
{
public virtual bool Equals(MultiChoiceOption? other)
{
return other is not null && (ReferenceEquals(this, other) || Value.Equals(other.Value));
}
public override int GetHashCode()
{
return Value.GetHashCode();
}
/// <remarks>
/// The string has been overriden to display the label only,
/// especially so the data can be easily displayed in XAML without a custom template, converter or code behind.
/// </remarks>
public override string ToString()
{
return Label;
}
}