File: System\Runtime\Serialization\MemberHolder.cs
Web Access
Project: src\src\libraries\System.Runtime.Serialization.Formatters\src\System.Runtime.Serialization.Formatters.csproj (System.Runtime.Serialization.Formatters)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Diagnostics.CodeAnalysis;
 
namespace System.Runtime.Serialization
{
    internal sealed class MemberHolder
    {
        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
        internal readonly Type _memberType;
        internal readonly StreamingContext _context;
 
        internal MemberHolder(
            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type,
            StreamingContext ctx)
        {
            _memberType = type;
            _context = ctx;
        }
 
        public override int GetHashCode() => _memberType.GetHashCode();
 
        public override bool Equals([NotNullWhen(true)] object? obj)
        {
            return obj is MemberHolder mh &&
                ReferenceEquals(mh._memberType, _memberType) &&
                mh._context.State == _context.State;
        }
    }
}