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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
using System.Windows;
using System.Windows.Controls;
namespace Gestor.Application.Helpers;
public static class PasswordBoxAssistant
{
public static readonly DependencyProperty BoundPassword = DependencyProperty.RegisterAttached("BoundPassword", typeof(string), typeof(PasswordBoxAssistant), new PropertyMetadata((object)string.Empty, new PropertyChangedCallback(OnBoundPasswordChanged)));
public static readonly DependencyProperty BindPassword = DependencyProperty.RegisterAttached("BindPassword", typeof(bool), typeof(PasswordBoxAssistant), new PropertyMetadata((object)false, new PropertyChangedCallback(OnBindPasswordChanged)));
private static readonly DependencyProperty UpdatingPassword = DependencyProperty.RegisterAttached("UpdatingPassword", typeof(bool), typeof(PasswordBoxAssistant), new PropertyMetadata((object)false));
private static void OnBoundPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
PasswordBox val = (PasswordBox)(object)((d is PasswordBox) ? d : null);
if (d != null && GetBindPassword(d))
{
val.PasswordChanged -= new RoutedEventHandler(HandlePasswordChanged);
string password = (string)((DependencyPropertyChangedEventArgs)(ref e)).NewValue;
if (!GetUpdatingPassword((DependencyObject)(object)val))
{
val.Password = password;
}
val.PasswordChanged += new RoutedEventHandler(HandlePasswordChanged);
}
}
private static void OnBindPasswordChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
PasswordBox val = (PasswordBox)(object)((dp is PasswordBox) ? dp : null);
if (val != null)
{
bool num = (bool)((DependencyPropertyChangedEventArgs)(ref e)).OldValue;
bool flag = (bool)((DependencyPropertyChangedEventArgs)(ref e)).NewValue;
if (num)
{
val.PasswordChanged -= new RoutedEventHandler(HandlePasswordChanged);
}
if (flag)
{
val.PasswordChanged += new RoutedEventHandler(HandlePasswordChanged);
}
}
}
private static void HandlePasswordChanged(object sender, RoutedEventArgs e)
{
PasswordBox val = (PasswordBox)((sender is PasswordBox) ? sender : null);
SetUpdatingPassword((DependencyObject)(object)val, value: true);
SetBoundPassword((DependencyObject)(object)val, val.Password);
SetUpdatingPassword((DependencyObject)(object)val, value: false);
}
public static void SetBindPassword(DependencyObject dp, bool value)
{
dp.SetValue(BindPassword, (object)value);
}
public static bool GetBindPassword(DependencyObject dp)
{
return (bool)dp.GetValue(BindPassword);
}
public static string GetBoundPassword(DependencyObject dp)
{
return (string)dp.GetValue(BoundPassword);
}
public static void SetBoundPassword(DependencyObject dp, string value)
{
dp.SetValue(BoundPassword, (object)value);
}
private static bool GetUpdatingPassword(DependencyObject dp)
{
return (bool)dp.GetValue(UpdatingPassword);
}
private static void SetUpdatingPassword(DependencyObject dp, bool value)
{
dp.SetValue(UpdatingPassword, (object)value);
}
}
|