ReSharper Reformat: Properties to expression bodied form.

This commit is contained in:
Erwin de Haan
2019-01-13 21:31:14 +01:00
parent 9fa60ec934
commit a36658f6f0
185 changed files with 782 additions and 3786 deletions

View File

@@ -51,13 +51,7 @@ namespace SocketHttpListener
/// <value>
/// A <see cref="ushort"/> that represents the status code for the close if any.
/// </value>
public ushort Code
{
get
{
return _code;
}
}
public ushort Code => _code;
/// <summary>
/// Gets the reason for the close.
@@ -65,13 +59,7 @@ namespace SocketHttpListener
/// <value>
/// A <see cref="string"/> that represents the reason for the close if any.
/// </value>
public string Reason
{
get
{
return _reason;
}
}
public string Reason => _reason;
/// <summary>
/// Gets a value indicating whether the WebSocket connection has been closed cleanly.
@@ -81,15 +69,9 @@ namespace SocketHttpListener
/// </value>
public bool WasClean
{
get
{
return _clean;
}
get => _clean;
internal set
{
_clean = value;
}
internal set => _clean = value;
}
#endregion

View File

@@ -35,13 +35,7 @@ namespace SocketHttpListener
/// <value>
/// A <see cref="string"/> that represents the error message.
/// </value>
public string Message
{
get
{
return _message;
}
}
public string Message => _message;
#endregion
}

View File

@@ -49,21 +49,9 @@ namespace SocketHttpListener
}
}
public QueryParamCollection Headers
{
get
{
return _headers;
}
}
public QueryParamCollection Headers => _headers;
public Version ProtocolVersion
{
get
{
return _version;
}
}
public Version ProtocolVersion => _version;
#endregion

View File

@@ -46,13 +46,7 @@ namespace SocketHttpListener
#region Public Properties
public CookieCollection Cookies
{
get
{
return GetCookies(Headers, true);
}
}
public CookieCollection Cookies => GetCookies(Headers, true);
private static CookieCollection GetCookies(QueryParamCollection headers, bool response)
{
@@ -62,21 +56,9 @@ namespace SocketHttpListener
: CookieHelper.Parse(headers[name], response);
}
public bool IsProxyAuthenticationRequired
{
get
{
return _code == "407";
}
}
public bool IsProxyAuthenticationRequired => _code == "407";
public bool IsUnauthorized
{
get
{
return _code == "401";
}
}
public bool IsUnauthorized => _code == "401";
public bool IsWebSocketResponse
{
@@ -90,21 +72,9 @@ namespace SocketHttpListener
}
}
public string Reason
{
get
{
return _reason;
}
}
public string Reason => _reason;
public string StatusCode
{
get
{
return _code;
}
}
public string StatusCode => _code;
#endregion

View File

@@ -48,13 +48,7 @@ namespace SocketHttpListener
/// <value>
/// A <see cref="string"/> that contains the received data.
/// </value>
public string Data
{
get
{
return _data;
}
}
public string Data => _data;
/// <summary>
/// Gets the received data as an array of <see cref="byte"/>.
@@ -62,13 +56,7 @@ namespace SocketHttpListener
/// <value>
/// An array of <see cref="byte"/> that contains the received data.
/// </value>
public byte[] RawData
{
get
{
return _rawData;
}
}
public byte[] RawData => _rawData;
/// <summary>
/// Gets the type of the received data.
@@ -76,13 +64,7 @@ namespace SocketHttpListener
/// <value>
/// One of the <see cref="Opcode"/> values, indicates the type of the received data.
/// </value>
public Opcode Type
{
get
{
return _opcode;
}
}
public Opcode Type => _opcode;
#endregion

View File

@@ -180,10 +180,7 @@ namespace SocketHttpListener.Net
InternalWrite(buffer, ref offset, size);
}
public bool WantMore
{
get { return (_chunkRead != _chunkSize || _chunkSize != 0 || _state != State.None); }
}
public bool WantMore => (_chunkRead != _chunkSize || _chunkSize != 0 || _state != State.None);
public bool DataAvailable
{
@@ -202,15 +199,9 @@ namespace SocketHttpListener.Net
}
}
public int TotalDataSize
{
get { return _totalWritten; }
}
public int TotalDataSize => _totalWritten;
public int ChunkLeft
{
get { return _chunkSize - _chunkRead; }
}
public int ChunkLeft => _chunkSize - _chunkRead;
private State ReadBody(byte[] buffer, ref int offset, int size)
{

View File

@@ -67,8 +67,8 @@ namespace SocketHttpListener.Net
public ChunkStream Decoder
{
get { return _decoder; }
set { _decoder = value; }
get => _decoder;
set => _decoder = value;
}
protected override int ReadCore(byte[] buffer, int offset, int count)

View File

@@ -89,13 +89,7 @@ namespace SocketHttpListener.Net
}
}
public Stream Stream
{
get
{
return _stream;
}
}
public Stream Stream => _stream;
public async Task Init()
{
@@ -131,15 +125,9 @@ namespace SocketHttpListener.Net
_context = new HttpListenerContext(this, _textEncoding);
}
public bool IsClosed
{
get { return (_socket == null); }
}
public bool IsClosed => (_socket == null);
public int Reuses
{
get { return _reuses; }
}
public int Reuses => _reuses;
public IPEndPoint LocalEndPoint
{
@@ -153,20 +141,14 @@ namespace SocketHttpListener.Net
}
}
public IPEndPoint RemoteEndPoint
{
get { return _socket.RemoteEndPoint as IPEndPoint; }
}
public IPEndPoint RemoteEndPoint => _socket.RemoteEndPoint as IPEndPoint;
public bool IsSecure
{
get { return secure; }
}
public bool IsSecure => secure;
public ListenerPrefix Prefix
{
get { return _prefix; }
set { _prefix = value; }
get => _prefix;
set => _prefix = value;
}
private void OnTimeout(object unused)

View File

@@ -58,13 +58,7 @@ namespace SocketHttpListener.Net
CreateSocket();
}
internal HttpListener Listener
{
get
{
return _listener;
}
}
internal HttpListener Listener => _listener;
private void CreateSocket()
{

View File

@@ -70,7 +70,7 @@ namespace SocketHttpListener.Net
// TODO: Digest, NTLM and Negotiate require ControlPrincipal
public AuthenticationSchemes AuthenticationSchemes
{
get { return auth_schemes; }
get => auth_schemes;
set
{
CheckDisposed();
@@ -80,7 +80,7 @@ namespace SocketHttpListener.Net
public AuthenticationSchemeSelector AuthenticationSchemeSelectorDelegate
{
get { return auth_selector; }
get => auth_selector;
set
{
CheckDisposed();
@@ -88,15 +88,9 @@ namespace SocketHttpListener.Net
}
}
public bool IsListening
{
get { return listening; }
}
public bool IsListening => listening;
public static bool IsSupported
{
get { return true; }
}
public static bool IsSupported => true;
public HttpListenerPrefixCollection Prefixes
{
@@ -110,7 +104,7 @@ namespace SocketHttpListener.Net
// TODO: use this
public string Realm
{
get { return realm; }
get => realm;
set
{
CheckDisposed();
@@ -120,7 +114,7 @@ namespace SocketHttpListener.Net
public bool UnsafeConnectionNtlmAuthentication
{
get { return unsafe_ntlm_auth; }
get => unsafe_ntlm_auth;
set
{
CheckDisposed();
@@ -142,10 +136,7 @@ namespace SocketHttpListener.Net
// }
//}
internal X509Certificate Certificate
{
get { return _certificate; }
}
internal X509Certificate Certificate => _certificate;
public void Abort()
{

View File

@@ -12,10 +12,7 @@ namespace SocketHttpListener.Net
this.password = password;
}
public virtual string Password
{
get { return password; }
}
public virtual string Password => password;
}
public class GenericIdentity : IIdentity
@@ -43,28 +40,10 @@ namespace SocketHttpListener.Net
m_type = type;
}
public virtual string Name
{
get
{
return m_name;
}
}
public virtual string Name => m_name;
public virtual string AuthenticationType
{
get
{
return m_type;
}
}
public virtual string AuthenticationType => m_type;
public virtual bool IsAuthenticated
{
get
{
return !m_name.Equals("");
}
}
public virtual bool IsAuthenticated => !m_name.Equals("");
}
}

View File

@@ -18,13 +18,7 @@ namespace SocketHttpListener.Net
// This can be used to cache the results of HttpListener.AuthenticationSchemeSelectorDelegate.
internal AuthenticationSchemes AuthenticationSchemes { get; set; }
public HttpListenerResponse Response
{
get
{
return _response;
}
}
public HttpListenerResponse Response => _response;
public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync(string subProtocol)
{
@@ -62,13 +56,7 @@ namespace SocketHttpListener.Net
}
}
public virtual IIdentity Identity
{
get
{
return m_identity;
}
}
public virtual IIdentity Identity => m_identity;
public virtual bool IsInRole(string role)
{

View File

@@ -18,20 +18,11 @@ namespace SocketHttpListener.Net
this.listener = listener;
}
public int Count
{
get { return prefixes.Count; }
}
public int Count => prefixes.Count;
public bool IsReadOnly
{
get { return false; }
}
public bool IsReadOnly => false;
public bool IsSynchronized
{
get { return false; }
}
public bool IsSynchronized => false;
public void Add(string uriPrefix)
{

View File

@@ -38,7 +38,7 @@ namespace SocketHttpListener.Net
public Version ProtocolVersion
{
get { return _version; }
get => _version;
set
{
CheckDisposed();
@@ -57,7 +57,7 @@ namespace SocketHttpListener.Net
public int StatusCode
{
get { return _statusCode; }
get => _statusCode;
set
{
CheckDisposed();

View File

@@ -15,16 +15,13 @@ namespace SocketHttpListener.Net
private string _statusDescription;
private WebHeaderCollection _webHeaders = new WebHeaderCollection();
public WebHeaderCollection Headers
{
get { return _webHeaders; }
}
public WebHeaderCollection Headers => _webHeaders;
public Encoding ContentEncoding { get; set; }
public string ContentType
{
get { return Headers["Content-Type"]; }
get => Headers["Content-Type"];
set
{
CheckDisposed();
@@ -39,13 +36,13 @@ namespace SocketHttpListener.Net
}
}
private HttpListenerContext HttpListenerContext { get { return _httpContext; } }
private HttpListenerContext HttpListenerContext => _httpContext;
private HttpListenerRequest HttpListenerRequest { get { return HttpListenerContext.Request; } }
private HttpListenerRequest HttpListenerRequest => HttpListenerContext.Request;
internal EntitySendFormat EntitySendFormat
{
get { return (EntitySendFormat)_boundaryType; }
get => (EntitySendFormat)_boundaryType;
set
{
CheckDisposed();
@@ -64,8 +61,8 @@ namespace SocketHttpListener.Net
public bool SendChunked
{
get { return EntitySendFormat == EntitySendFormat.Chunked; }
set { EntitySendFormat = value ? EntitySendFormat.Chunked : EntitySendFormat.ContentLength; }
get => EntitySendFormat == EntitySendFormat.Chunked;
set => EntitySendFormat = value ? EntitySendFormat.Chunked : EntitySendFormat.ContentLength;
}
// We MUST NOT send message-body when we send responses with these Status codes
@@ -85,7 +82,7 @@ namespace SocketHttpListener.Net
public long ContentLength64
{
get { return _contentLength; }
get => _contentLength;
set
{
CheckDisposed();
@@ -104,13 +101,13 @@ namespace SocketHttpListener.Net
public CookieCollection Cookies
{
get { return _cookies ?? (_cookies = new CookieCollection()); }
set { _cookies = value; }
get => _cookies ?? (_cookies = new CookieCollection());
set => _cookies = value;
}
public bool KeepAlive
{
get { return _keepAlive; }
get => _keepAlive;
set
{
CheckDisposed();
@@ -130,7 +127,7 @@ namespace SocketHttpListener.Net
public string RedirectLocation
{
get { return Headers["Location"]; }
get => Headers["Location"];
set
{
// note that this doesn't set the status code to a redirect one

View File

@@ -84,25 +84,13 @@ namespace SocketHttpListener.Net
public override void Flush() { }
public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask;
public override long Length
{
get
{
throw new NotImplementedException();
}
}
public override long Length => throw new NotImplementedException();
public override long Position
{
get
{
throw new NotImplementedException();
}
get => throw new NotImplementedException();
set
{
throw new NotImplementedException();
}
set => throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)

View File

@@ -17,25 +17,13 @@ namespace SocketHttpListener.Net
public override void Flush() { }
public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask;
public override long Length
{
get
{
throw new NotImplementedException();
}
}
public override long Length => throw new NotImplementedException();
public override long Position
{
get
{
throw new NotImplementedException();
}
get => throw new NotImplementedException();
set
{
throw new NotImplementedException();
}
set => throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)

View File

@@ -47,10 +47,7 @@ namespace SocketHttpListener.Net
}
}
public object AsyncState
{
get { return _state; }
}
public object AsyncState => _state;
public WaitHandle AsyncWaitHandle
{

View File

@@ -26,28 +26,16 @@ namespace SocketHttpListener.Net
public IPAddress[] Addresses
{
get { return _addresses; }
set { _addresses = value; }
}
public bool Secure
{
get { return _secure; }
get => _addresses;
set => _addresses = value;
}
public bool Secure => _secure;
public string Host
{
get { return _host; }
}
public string Host => _host;
public int Port
{
get { return _port; }
}
public int Port => _port;
public string Path
{
get { return _path; }
}
public string Path => _path;
// Equals and GetHashCode are required to detect duplicates in HttpListenerPrefixCollection.
public override bool Equals(object o)

View File

@@ -54,50 +54,21 @@ namespace SocketHttpListener
#region Internal Properties
internal bool ContainsReservedCloseStatusCode
{
get
{
return _applicationData.Length > 1 &&
_applicationData.SubArray(0, 2).ToUInt16(ByteOrder.Big).IsReserved();
}
}
internal bool ContainsReservedCloseStatusCode =>
_applicationData.Length > 1 &&
_applicationData.SubArray(0, 2).ToUInt16(ByteOrder.Big).IsReserved();
#endregion
#region Public Properties
public byte[] ApplicationData
{
get
{
return _applicationData;
}
}
public byte[] ApplicationData => _applicationData;
public byte[] ExtensionData
{
get
{
return _extensionData;
}
}
public byte[] ExtensionData => _extensionData;
public bool IsMasked
{
get
{
return _masked;
}
}
public bool IsMasked => _masked;
public ulong Length
{
get
{
return (ulong)(_extensionData.Length + _applicationData.Length);
}
}
public ulong Length => (ulong)(_extensionData.Length + _applicationData.Length);
#endregion

View File

@@ -17,26 +17,18 @@ namespace SocketHttpListener
{
}
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return true; }
}
public override long Length
{
get { throw new NotImplementedException(); }
}
public override bool CanRead => true;
public override bool CanSeek => false;
public override bool CanWrite => true;
public override long Length => throw new NotImplementedException();
public override long Position
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)

View File

@@ -78,11 +78,7 @@ namespace SocketHttpListener
init();
}
public static TimeSpan DefaultKeepAliveInterval
{
// In the .NET Framework, this pulls the value from a P/Invoke. Here we just hardcode it to a reasonable default.
get { return TimeSpan.FromSeconds(30); }
}
public static TimeSpan DefaultKeepAliveInterval => TimeSpan.FromSeconds(30);
#endregion
@@ -93,13 +89,7 @@ namespace SocketHttpListener
/// One of the <see cref="WebSocketState"/> enum values, indicates the state of the WebSocket
/// connection. The default value is <see cref="WebSocketState.Connecting"/>.
/// </value>
public WebSocketState ReadyState
{
get
{
return _readyState;
}
}
public WebSocketState ReadyState => _readyState;
#region Public Events

View File

@@ -106,197 +106,53 @@ namespace SocketHttpListener
#region Public Properties
public byte[] ExtendedPayloadLength
{
get
{
return _extPayloadLength;
}
}
public byte[] ExtendedPayloadLength => _extPayloadLength;
public Fin Fin
{
get
{
return _fin;
}
}
public Fin Fin => _fin;
public bool IsBinary
{
get
{
return _opcode == Opcode.Binary;
}
}
public bool IsBinary => _opcode == Opcode.Binary;
public bool IsClose
{
get
{
return _opcode == Opcode.Close;
}
}
public bool IsClose => _opcode == Opcode.Close;
public bool IsCompressed
{
get
{
return _rsv1 == Rsv.On;
}
}
public bool IsCompressed => _rsv1 == Rsv.On;
public bool IsContinuation
{
get
{
return _opcode == Opcode.Cont;
}
}
public bool IsContinuation => _opcode == Opcode.Cont;
public bool IsControl
{
get
{
return _opcode == Opcode.Close || _opcode == Opcode.Ping || _opcode == Opcode.Pong;
}
}
public bool IsControl => _opcode == Opcode.Close || _opcode == Opcode.Ping || _opcode == Opcode.Pong;
public bool IsData
{
get
{
return _opcode == Opcode.Binary || _opcode == Opcode.Text;
}
}
public bool IsData => _opcode == Opcode.Binary || _opcode == Opcode.Text;
public bool IsFinal
{
get
{
return _fin == Fin.Final;
}
}
public bool IsFinal => _fin == Fin.Final;
public bool IsFragmented
{
get
{
return _fin == Fin.More || _opcode == Opcode.Cont;
}
}
public bool IsFragmented => _fin == Fin.More || _opcode == Opcode.Cont;
public bool IsMasked
{
get
{
return _mask == Mask.Mask;
}
}
public bool IsMasked => _mask == Mask.Mask;
public bool IsPerMessageCompressed
{
get
{
return (_opcode == Opcode.Binary || _opcode == Opcode.Text) && _rsv1 == Rsv.On;
}
}
public bool IsPerMessageCompressed => (_opcode == Opcode.Binary || _opcode == Opcode.Text) && _rsv1 == Rsv.On;
public bool IsPing
{
get
{
return _opcode == Opcode.Ping;
}
}
public bool IsPing => _opcode == Opcode.Ping;
public bool IsPong
{
get
{
return _opcode == Opcode.Pong;
}
}
public bool IsPong => _opcode == Opcode.Pong;
public bool IsText
{
get
{
return _opcode == Opcode.Text;
}
}
public bool IsText => _opcode == Opcode.Text;
public ulong Length
{
get
{
return 2 + (ulong)(_extPayloadLength.Length + _maskingKey.Length) + _payloadData.Length;
}
}
public ulong Length => 2 + (ulong)(_extPayloadLength.Length + _maskingKey.Length) + _payloadData.Length;
public Mask Mask
{
get
{
return _mask;
}
}
public Mask Mask => _mask;
public byte[] MaskingKey
{
get
{
return _maskingKey;
}
}
public byte[] MaskingKey => _maskingKey;
public Opcode Opcode
{
get
{
return _opcode;
}
}
public Opcode Opcode => _opcode;
public PayloadData PayloadData
{
get
{
return _payloadData;
}
}
public PayloadData PayloadData => _payloadData;
public byte PayloadLength
{
get
{
return _payloadLength;
}
}
public byte PayloadLength => _payloadLength;
public Rsv Rsv1
{
get
{
return _rsv1;
}
}
public Rsv Rsv1 => _rsv1;
public Rsv Rsv2
{
get
{
return _rsv2;
}
}
public Rsv Rsv2 => _rsv2;
public Rsv Rsv3
{
get
{
return _rsv3;
}
}
public Rsv Rsv3 => _rsv3;
#endregion