-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPinSetConverter.cs
39 lines (35 loc) · 1.03 KB
/
PinSetConverter.cs
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
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Data;
using System.Windows.Markup;
namespace WPF_dnscrypt_proxy_md
{
public class PinSetConverter : MarkupExtension, IValueConverter
{
public PinSetConverter() { }
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if(value is JArray ja)
{
return ja.ToString();
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if(value is string json)
{
return JArray.Parse(json);
}
return new JArray();
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}