Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CanFormatWith()

bool Terraria.Localization.LocalizedText.CanFormatWith ( object obj)
inline

Definition at line 43 of file LocalizedText.cs.

44 {
46 foreach (Match item in _substitutionRegex.Matches(Value))
47 {
48 string name = item.Groups[2].ToString();
49 PropertyDescriptor propertyDescriptor = properties.Find(name, ignoreCase: false);
50 if (propertyDescriptor == null)
51 {
52 return false;
53 }
54 object value = propertyDescriptor.GetValue(obj);
55 if (value == null)
56 {
57 return false;
58 }
59 if (item.Groups[1].Length != 0 && (((value as bool?) ?? false) ^ (item.Groups[1].Length == 1)))
60 {
61 return false;
62 }
63 }
64 return true;
65 }
virtual ? PropertyDescriptor Find(string name, bool ignoreCase)
object? GetValue(object? component)
static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)

References Terraria.Localization.LocalizedText._substitutionRegex, System.ComponentModel.TypeDescriptor.GetProperties(), System.ComponentModel.PropertyDescriptor.GetValue(), System.Text.RegularExpressions.name, System.Text.RegularExpressions.value, and Terraria.Localization.LocalizedText.Value.