Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CountPropertyHelper.cs
Go to the documentation of this file.
4
6
7internal static class CountPropertyHelper
8{
9 [RequiresUnreferencedCode("Uses reflection to get the 'Count' property on types that don't implement ICollection. This 'Count' property may be trimmed. Ensure it is preserved.")]
10 public static bool TryGetCount(object value, out int count)
11 {
13 {
14 count = collection.Count;
15 return true;
16 }
17 PropertyInfo runtimeProperty = value.GetType().GetRuntimeProperty("Count");
18 if (runtimeProperty != null && runtimeProperty.CanRead && runtimeProperty.PropertyType == typeof(int))
19 {
20 count = (int)runtimeProperty.GetValue(value);
21 return true;
22 }
23 count = -1;
24 return false;
25 }
26}
static bool TryGetCount(object value, out int count)
object? GetValue(object? obj)