summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Reflection/CacheEntry.cs
blob: 27f48a1f0a3b84714b0422a5e7b0889c4de5ba39 (plain)
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
using System.Diagnostics.CodeAnalysis;
using System.Reflection;

namespace StardewModdingAPI.Framework.Reflection
{
    /// <summary>A cached member reflection result.</summary>
    internal readonly struct CacheEntry
    {
        /*********
        ** Accessors
        *********/
        /// <summary>Whether the lookup found a valid match.</summary>
        [MemberNotNullWhen(true, nameof(CacheEntry.MemberInfo))]
        public bool IsValid => this.MemberInfo != null;

        /// <summary>The reflection data for this member (or <c>null</c> if invalid).</summary>
        public MemberInfo? MemberInfo { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="memberInfo">The reflection data for this member (or <c>null</c> if invalid).</param>
        public CacheEntry(MemberInfo? memberInfo)
        {
            this.MemberInfo = memberInfo;
        }
    }
}