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;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-31 01:09:32 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|