-
Notifications
You must be signed in to change notification settings - Fork 805
Expand file tree
/
Copy pathNetworkProfileToStringConverter.cs
More file actions
42 lines (39 loc) · 1.48 KB
/
NetworkProfileToStringConverter.cs
File metadata and controls
42 lines (39 loc) · 1.48 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
36
37
38
39
40
41
42
using System;
using System.Globalization;
using System.Windows.Data;
using NETworkManager.Localization.Resources;
using NETworkManager.Models.Network;
namespace NETworkManager.Converters;
/// <summary>
/// Convert <see cref="NetworkProfile" /> to a localized <see cref="string" /> or vice versa.
/// </summary>
public sealed class NetworkProfileToStringConverter : IValueConverter
{
/// <summary>
/// Convert <see cref="NetworkProfile" /> to a localized <see cref="string" />.
/// </summary>
/// <param name="value">Object from type <see cref="NetworkProfile" />.</param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns>Localized <see cref="string" /> representing the network profile.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is not NetworkProfile profile
? "-/-"
: profile switch
{
NetworkProfile.Domain => Strings.Domain,
NetworkProfile.Private => Strings.Private,
NetworkProfile.Public => Strings.Public,
_ => "-/-"
};
}
/// <summary>
/// !!! Method not implemented !!!
/// </summary>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}