Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
|
|
@ -40,44 +40,30 @@ namespace Server {
|
|||
}
|
||||
#endif
|
||||
|
||||
private static int bufferSize = 1 * MB;
|
||||
private static int concurrency = 1;
|
||||
public static int BufferSize { get; set; } = 1 * MB;
|
||||
|
||||
private static bool unbuffered = true;
|
||||
public static int Concurrency { get; set; } = 1;
|
||||
|
||||
public static int BufferSize {
|
||||
get => bufferSize;
|
||||
set => bufferSize = value;
|
||||
}
|
||||
public static bool Unbuffered { get; set; } = true;
|
||||
|
||||
public static int Concurrency {
|
||||
get => concurrency;
|
||||
set => concurrency = value;
|
||||
}
|
||||
public static bool AreSynchronous => ( Concurrency < 1 );
|
||||
|
||||
public static bool Unbuffered {
|
||||
get => unbuffered;
|
||||
set => unbuffered = value;
|
||||
}
|
||||
|
||||
public static bool AreSynchronous => ( concurrency < 1 );
|
||||
|
||||
public static bool AreAsynchronous => ( concurrency > 0 );
|
||||
public static bool AreAsynchronous => ( Concurrency > 0 );
|
||||
|
||||
public static FileStream OpenSequentialStream( string path, FileMode mode, FileAccess access, FileShare share ) {
|
||||
FileOptions options = FileOptions.SequentialScan;
|
||||
|
||||
if ( concurrency > 0 ) {
|
||||
if ( Concurrency > 0 ) {
|
||||
options |= FileOptions.Asynchronous;
|
||||
}
|
||||
|
||||
#if MONO
|
||||
return new FileStream( path, mode, access, share, bufferSize, options );
|
||||
#else
|
||||
if ( unbuffered ) {
|
||||
if ( Unbuffered ) {
|
||||
options |= NoBuffering;
|
||||
} else {
|
||||
return new FileStream( path, mode, access, share, bufferSize, options );
|
||||
return new FileStream( path, mode, access, share, BufferSize, options );
|
||||
}
|
||||
|
||||
SafeFileHandle fileHandle = UnsafeNativeMethods.CreateFile(path, (int)access, share, IntPtr.Zero, mode, (int)options, IntPtr.Zero);
|
||||
|
|
@ -86,7 +72,7 @@ namespace Server {
|
|||
throw new IOException();
|
||||
}
|
||||
|
||||
return new UnbufferedFileStream( fileHandle, access, bufferSize, ( concurrency > 0 ) );
|
||||
return new UnbufferedFileStream( fileHandle, access, BufferSize, ( Concurrency > 0 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -100,11 +86,11 @@ namespace Server {
|
|||
}
|
||||
|
||||
public override void Write( byte[] array, int offset, int count ) {
|
||||
base.Write( array, offset, bufferSize );
|
||||
base.Write( array, offset, BufferSize );
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginWrite( byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject ) {
|
||||
return base.BeginWrite( array, offset, bufferSize, userCallback, stateObject );
|
||||
return base.BeginWrite( array, offset, BufferSize, userCallback, stateObject );
|
||||
}
|
||||
|
||||
protected override void Dispose( bool disposing ) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue