2019-06-12 21:56:55 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Capnp
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ListDeserializer specialization for empty lists.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class EmptyListDeserializer : ListDeserializer
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Always ListKind.ListOfEmpty (despite the fact the empty list != List(Void)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public override ListKind Kind => ListKind.ListOfEmpty;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns am empty <see cref="IReadOnlyList{T}"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">Element ype</typeparam>
|
|
|
|
|
/// <param name="cons">Ignored</param>
|
|
|
|
|
public override IReadOnlyList<T> Cast<T>(Func<DeserializerState, T> cons) => new EmptyList<T>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<bool>]]></code>/>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<bool> CastBool() => new EmptyList<bool>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<byte>]]></code>/>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<byte> CastByte() => new EmptyList<byte>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<double>]]></code>/>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<double> CastDouble() => new EmptyList<double>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<float>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<float> CastFloat() => new EmptyList<float>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<int>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<int> CastInt() => new EmptyList<int>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<ListDeserializer>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<ListDeserializer> CastList() => new EmptyList<ListDeserializer>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<long>]]></code>/>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<long> CastLong() => new EmptyList<long>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<sbyte>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<sbyte> CastSByte() => new EmptyList<sbyte>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<short>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<short> CastShort() => new EmptyList<short>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns an empty string.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public override string CastText() => string.Empty;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<uint>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<uint> CastUInt() => new EmptyList<uint>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<ulong>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<ulong> CastULong() => new EmptyList<ulong>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-07-12 21:48:01 +02:00
|
|
|
|
/// Returns an empty <code><![CDATA[IReadOnlyList<ushort>]]></code>.
|
2019-06-12 21:56:55 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
public override IReadOnlyList<ushort> CastUShort() => new EmptyList<ushort>();
|
|
|
|
|
}
|
2020-01-11 17:56:12 +01:00
|
|
|
|
}
|