Plane.Sdk3/PlaneGcsSdk_Shared/Communication/EmptyConnection.cs

45 lines
979 B
C#
Raw Normal View History

2017-02-27 02:02:19 +08:00
using System.Threading.Tasks;
namespace Plane.Communication
{
/// <summary>
/// <see cref="IConnection"/> 的空白实现。
/// </summary>
public class EmptyConnection : ExceptionThrownEventSource, IConnection
{
private EmptyConnection()
{
}
public static EmptyConnection Instance { get; } = new EmptyConnection();
public bool IsOpen { get; private set; }
public void Close()
{
IsOpen = false;
}
public int BytesToRead()
{
return 0;
}
2017-02-27 02:02:19 +08:00
public Task OpenAsync()
{
IsOpen = true;
return TaskUtils.CompletedTask;
}
public Task<int> ReadAsync(byte[] buffer, int offset, int count)
{
return Task.FromResult(count);
}
public Task WriteAsync(byte[] buffer, int offset, int count)
{
return TaskUtils.CompletedTask;
}
}
}