Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
BindableAttribute.cs
Go to the documentation of this file.
2
4
5[AttributeUsage(AttributeTargets.All)]
6public sealed class BindableAttribute : Attribute
7{
8 public static readonly BindableAttribute Yes = new BindableAttribute(bindable: true);
9
10 public static readonly BindableAttribute No = new BindableAttribute(bindable: false);
11
12 public static readonly BindableAttribute Default = No;
13
14 private readonly bool _isDefault;
15
16 public bool Bindable { get; }
17
19
20 public BindableAttribute(bool bindable)
21 : this(bindable, BindingDirection.OneWay)
22 {
23 }
24
25 public BindableAttribute(bool bindable, BindingDirection direction)
26 {
27 Bindable = bindable;
28 Direction = direction;
29 }
30
32 : this(flags, BindingDirection.OneWay)
33 {
34 }
35
37 {
38 Bindable = flags != BindableSupport.No;
39 _isDefault = flags == BindableSupport.Default;
40 Direction = direction;
41 }
42
43 public override bool Equals([NotNullWhen(true)] object? obj)
44 {
45 if (obj == this)
46 {
47 return true;
48 }
49 if (obj is BindableAttribute bindableAttribute)
50 {
51 return bindableAttribute.Bindable == Bindable;
52 }
53 return false;
54 }
55
56 public override int GetHashCode()
57 {
58 return Bindable.GetHashCode();
59 }
60
61 public override bool IsDefaultAttribute()
62 {
63 if (!Equals(Default))
64 {
65 return _isDefault;
66 }
67 return true;
68 }
69}
override bool Equals([NotNullWhen(true)] object? obj)
static readonly BindableAttribute Yes
BindableAttribute(BindableSupport flags, BindingDirection direction)
static readonly BindableAttribute Default
static readonly BindableAttribute No
BindableAttribute(bool bindable, BindingDirection direction)