mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +01:00
54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace Capnp.Rpc
|
|
{
|
|
/// <summary>
|
|
/// Null capability
|
|
/// </summary>
|
|
public sealed class NullCapability : ConsumedCapability
|
|
{
|
|
/// <summary>
|
|
/// Singleton instance
|
|
/// </summary>
|
|
public static readonly NullCapability Instance = new NullCapability();
|
|
|
|
NullCapability()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Does nothing
|
|
/// </summary>
|
|
protected override void ReleaseRemotely()
|
|
{
|
|
}
|
|
|
|
internal override void AddRef()
|
|
{
|
|
}
|
|
|
|
internal override Skeleton AsSkeleton() => NullSkeleton.Instance;
|
|
|
|
internal override IPromisedAnswer DoCall(ulong interfaceId, ushort methodId, DynamicSerializerState args)
|
|
{
|
|
args.Dispose();
|
|
throw new InvalidOperationException("Cannot call null capability");
|
|
}
|
|
|
|
internal override Action? Export(IRpcEndpoint endpoint, CapDescriptor.WRITER writer)
|
|
{
|
|
writer.which = CapDescriptor.WHICH.None;
|
|
return null;
|
|
}
|
|
|
|
internal override void Release()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// String hint
|
|
/// </summary>
|
|
/// <returns>"Null capability"</returns>
|
|
public override string ToString() => "Null capability";
|
|
}
|
|
} |