AyCode.Core/AyCode.Core/Serializers/Binaries/BinaryPropertyAccessorBase.cs

38 lines
1.3 KiB
C#

using System.Reflection;
using System.Runtime.CompilerServices;
using static AyCode.Core.Helpers.JsonUtilities;
namespace AyCode.Core.Serializers.Binaries;
/// <summary>
/// Binary-specific property accessor.
/// Inherits typed getters from PropertyAccessorBase.
/// Adds Binary-specific properties: PropertyIndex, CachedPropertyNameIndex.
/// </summary>
public abstract class BinaryPropertyAccessorBase : PropertyAccessorBase
{
/// <summary>
/// Cached property name index for metadata mode. Set by context during registration.
/// -1 means not yet cached.
/// </summary>
internal int CachedPropertyNameIndex = -1;
/// <summary>
/// Deterministic property index based on alphabetical ordering of property names.
/// This is computed once during metadata creation and is consistent across all platforms.
/// Used for fast serialization without dictionary lookup.
/// </summary>
public int PropertyIndex { get; internal set; } = -1;
/// <summary>
/// Object getter for property filter context.
/// </summary>
public Func<object, object?> DynamicGetter => _dynamicGetter;
protected BinaryPropertyAccessorBase(PropertyInfo prop, Type declaringType)
: base(prop, declaringType)
{
// All typed getters are initialized in PropertyAccessorBase
}
}