File: System\Runtime\Serialization\BinaryFormat\ObjectNullMultiple256Record.cs
Web Access
Project: src\src\libraries\System.Runtime.Serialization.BinaryFormat\src\System.Runtime.Serialization.BinaryFormat.csproj (System.Runtime.Serialization.BinaryFormat)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.IO;
using System.Runtime.Serialization.BinaryFormat.Utils;
 
namespace System.Runtime.Serialization.BinaryFormat;
 
/// <summary>
/// Represents multiple (less than 256) <see langword="null" />.
/// </summary>
/// <remarks>
/// ObjectNullMultiple256 records are described in <see href="https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-nrbf/24ae84a0-781f-45bf-a1ac-49f6a65af5dd">[MS-NRBF] 2.5.6</see>.
/// </remarks>
internal sealed class ObjectNullMultiple256Record : NullsRecord
{
    private ObjectNullMultiple256Record(byte count) => NullCount = count;
 
    public override RecordType RecordType => RecordType.ObjectNullMultiple256;
 
    internal override int NullCount { get; }
 
    internal static ObjectNullMultiple256Record Decode(BinaryReader reader)
    {
        // The NRBF spec for 2.5.6 ObjectNullMultiple allows for 0, but we don't.
        byte count = reader.ReadByte();
        if (count == 0)
        {
            ThrowHelper.ThrowInvalidValue(count);
        }
 
        return new ObjectNullMultiple256Record(count);
    }
}