Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MemberRelationshipService.cs
Go to the documentation of this file.
3
5
6public abstract class MemberRelationshipService
7{
8 private struct RelationshipEntry
9 {
11
13
14 private readonly int _hashCode;
15
17 {
18 _owner = new WeakReference(rel.Owner);
19 _member = rel.Member;
20 _hashCode = ((rel.Owner != null) ? rel.Owner.GetHashCode() : 0);
21 }
22
23 public override bool Equals([NotNullWhen(true)] object o)
24 {
25 return this == (RelationshipEntry)o;
26 }
27
29 {
30 object obj = (re1._owner.IsAlive ? re1._owner.Target : null);
31 object obj2 = (re2._owner.IsAlive ? re2._owner.Target : null);
32 if (obj == obj2)
33 {
34 return re1._member.Equals(re2._member);
35 }
36 return false;
37 }
38
39 public override int GetHashCode()
40 {
41 return _hashCode;
42 }
43 }
44
46
48 {
49 get
50 {
51 if (source.Owner == null)
52 {
53 throw new ArgumentException(System.SR.Format(System.SR.InvalidNullArgument, "source.Owner"), "source");
54 }
55 return GetRelationship(source);
56 }
57 set
58 {
59 if (source.Owner == null)
60 {
61 throw new ArgumentException(System.SR.Format(System.SR.InvalidNullArgument, "source.Owner"), "source");
62 }
64 }
65 }
66
68 {
69 get
70 {
71 if (sourceOwner == null)
72 {
73 throw new ArgumentNullException("sourceOwner");
74 }
75 if (sourceMember == null)
76 {
77 throw new ArgumentNullException("sourceMember");
78 }
80 }
81 set
82 {
83 if (sourceOwner == null)
84 {
85 throw new ArgumentNullException("sourceOwner");
86 }
87 if (sourceMember == null)
88 {
89 throw new ArgumentNullException("sourceMember");
90 }
92 }
93 }
94
96 {
98 {
99 return new MemberRelationship(value._owner.Target, value._member);
100 }
102 }
103
112
113 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "GetComponentName is only used to create a nice exception message, and has a fallback when null is returned.")]
115 {
118 if (text == null)
119 {
120 text = source.Owner.ToString();
121 }
122 if (text2 == null)
123 {
124 text2 = relationship.Owner.ToString();
125 }
127 }
128
130}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
static void ThrowRelationshipNotSupported(MemberRelationship source, MemberRelationship relationship)
virtual void SetRelationship(MemberRelationship source, MemberRelationship relationship)
virtual MemberRelationship GetRelationship(MemberRelationship source)
readonly Dictionary< RelationshipEntry, RelationshipEntry > _relationships
bool SupportsRelationship(MemberRelationship source, MemberRelationship relationship)
static ? string GetComponentName(object component)
static string InvalidNullArgument
Definition SR.cs:86
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string MemberRelationshipService_RelationshipNotSupported
Definition SR.cs:130
Definition SR.cs:7