33 lines
1.0 KiB
C#
Raw Permalink Normal View History

2019-06-12 21:56:55 +02:00
using System;
namespace Capnp
{
/// <summary>
/// SerializerState specialization for List(Void).
/// </summary>
public class ListOfEmptySerializer:
SerializerState
{
/// <summary>
/// This list's element count.
/// </summary>
public int Count => ListElementCount;
/// <summary>
/// Initializes this list with a specific size. The list can be initialized only once.
/// </summary>
/// <param name="count">List element count</param>
/// <exception cref="InvalidOperationException">The list was already initialized</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is negative or greater than 2^29-1</exception>
public void Init(int count)
{
if (IsAllocated)
throw new InvalidOperationException("Already initialized");
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
SetListOfValues(0, count);
}
}
2020-01-11 17:56:12 +01:00
}