Skip to content

Commit

Permalink
many code quality fixes, release 26.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
robinrodricks committed Jul 22, 2019
1 parent 609c101 commit 9874f80
Show file tree
Hide file tree
Showing 116 changed files with 6,929 additions and 6,583 deletions.
14 changes: 5 additions & 9 deletions FluentFTP.Examples/AsyncConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@
using System.Threading.Tasks;
using FluentFTP;

namespace Examples
{
static class AsyncConnectExample
{
public static async Task AsyncConnectAsync()
{
namespace Examples {
internal static class AsyncConnectExample {
public static async Task AsyncConnectAsync() {
var cts = new CancellationTokenSource(10000);
using (var conn = new FtpClient())
{
using (var conn = new FtpClient()) {
conn.Host = "127.0.0.1";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
await conn.ConnectAsync(cts.Token);
await conn.UploadAsync(new byte[1000 * 1000], "test/file", createRemoteDir: true, token: cts.Token);
}
}
}
}
}
62 changes: 31 additions & 31 deletions FluentFTP.Examples/BeginConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@
using System.Threading;

namespace Examples {
public static class BeginConnectExample {
static ManualResetEvent m_reset = new ManualResetEvent(false);
public static class BeginConnectExample {
private static ManualResetEvent m_reset = new ManualResetEvent(false);

public static void BeginConnect() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (FtpClient conn = new FtpClient()) {
m_reset.Reset();

conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.BeginConnect(new AsyncCallback(ConnectCallback), conn);
public static void BeginConnect() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (var conn = new FtpClient()) {
m_reset.Reset();

m_reset.WaitOne();
conn.Disconnect();
}
}
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.BeginConnect(new AsyncCallback(ConnectCallback), conn);

static void ConnectCallback(IAsyncResult ar) {
FtpClient conn = ar.AsyncState as FtpClient;
m_reset.WaitOne();
conn.Disconnect();
}
}

try {
private static void ConnectCallback(IAsyncResult ar) {
var conn = ar.AsyncState as FtpClient;

try {
if (conn == null) {
throw new InvalidOperationException("The FtpControlConnection object is null!");
}

conn.EndConnect(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
conn.EndConnect(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
64 changes: 32 additions & 32 deletions FluentFTP.Examples/BeginCreateDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,44 @@
using FluentFTP;

namespace Examples {
public static class BeginCreateDirectoryExample {
static ManualResetEvent m_reset = new ManualResetEvent(false);
public static class BeginCreateDirectoryExample {
private static ManualResetEvent m_reset = new ManualResetEvent(false);

public static void BeginCreateDirectory() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (FtpClient conn = new FtpClient()) {
m_reset.Reset();
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
public static void BeginCreateDirectory() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (var conn = new FtpClient()) {
m_reset.Reset();

conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.DeleteDirectory("/test");
conn.BeginCreateDirectory("/test/path/that/should/be/created", true,
new AsyncCallback(CreateDirectoryCallback), conn);
conn.BeginCreateDirectory("/test/path/that/should/be/created", true,
new AsyncCallback(CreateDirectoryCallback), conn);

m_reset.WaitOne();
conn.Disconnect();
}
}
m_reset.WaitOne();
conn.Disconnect();
}
}

static void CreateDirectoryCallback(IAsyncResult ar) {
FtpClient conn = ar.AsyncState as FtpClient;
private static void CreateDirectoryCallback(IAsyncResult ar) {
var conn = ar.AsyncState as FtpClient;

try {
try {
if (conn == null) {
throw new InvalidOperationException("The FtpControlConnection object is null!");
}

conn.EndCreateDirectory(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
conn.EndCreateDirectory(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
62 changes: 31 additions & 31 deletions FluentFTP.Examples/BeginDeleteDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@
using System.Threading;

namespace Examples {
class BeginDeleteDirectoryExample {
static ManualResetEvent m_reset = new ManualResetEvent(false);
internal class BeginDeleteDirectoryExample {
private static ManualResetEvent m_reset = new ManualResetEvent(false);

public static void BeginDeleteDirectory() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (FtpClient conn = new FtpClient()) {
m_reset.Reset();
public static void BeginDeleteDirectory() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (var conn = new FtpClient()) {
m_reset.Reset();

conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.CreateDirectory("/some/test/directory");
conn.BeginDeleteDirectory("/some", new AsyncCallback(DeleteDirectoryCallback), conn);
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.CreateDirectory("/some/test/directory");
conn.BeginDeleteDirectory("/some", new AsyncCallback(DeleteDirectoryCallback), conn);

m_reset.WaitOne();
conn.Disconnect();
}
}
m_reset.WaitOne();
conn.Disconnect();
}
}

static void DeleteDirectoryCallback(IAsyncResult ar) {
FtpClient conn = ar.AsyncState as FtpClient;
private static void DeleteDirectoryCallback(IAsyncResult ar) {
var conn = ar.AsyncState as FtpClient;

try {
try {
if (conn == null) {
throw new InvalidOperationException("The FtpControlConnection object is null!");
}

conn.EndDeleteDirectory(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
conn.EndDeleteDirectory(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
62 changes: 31 additions & 31 deletions FluentFTP.Examples/BeginDeleteFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@
using System.Threading;

namespace Examples {
public static class BeginDeleteFileExample {
static ManualResetEvent m_reset = new ManualResetEvent(false);
public static class BeginDeleteFileExample {
private static ManualResetEvent m_reset = new ManualResetEvent(false);

public static void BeginDeleteFile() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (FtpClient conn = new FtpClient()) {
m_reset.Reset();

conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.BeginDeleteFile("/path/to/file", new AsyncCallback(DeleteFileCallback), conn);
public static void BeginDeleteFile() {
// The using statement here is OK _only_ because m_reset.WaitOne()
// causes the code to block until the async process finishes, otherwise
// the connection object would be disposed early. In practice, you
// typically would not wrap the following code with a using statement.
using (var conn = new FtpClient()) {
m_reset.Reset();

m_reset.WaitOne();
conn.Disconnect();
}
}
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.BeginDeleteFile("/path/to/file", new AsyncCallback(DeleteFileCallback), conn);

static void DeleteFileCallback(IAsyncResult ar) {
FtpClient conn = ar.AsyncState as FtpClient;
m_reset.WaitOne();
conn.Disconnect();
}
}

try {
private static void DeleteFileCallback(IAsyncResult ar) {
var conn = ar.AsyncState as FtpClient;

try {
if (conn == null) {
throw new InvalidOperationException("The FtpControlConnection object is null!");
}

conn.EndDeleteFile(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
conn.EndDeleteFile(ar);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
finally {
m_reset.Set();
}
}
}
}
Loading

0 comments on commit 9874f80

Please sign in to comment.