slight reorga

pull/27/head
Miepee 5 years ago
parent 41995cad2d
commit 829ef9b44c

@ -1,6 +1,8 @@
using System;
using log4net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
@ -8,6 +10,12 @@ namespace AM2RLauncher.Helpers
{
static class HelperMethods
{
// Load reference to logger
/// <summary>
/// Our log object, that handles logging the current execution to a file.
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(MainForm));
// Thank you, Microsoft docs: https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
// Slightly modified by adding overwriteFiles bool, as we need to replace readme, music, etc.
/// <summary>
@ -136,5 +144,27 @@ namespace AM2RLauncher.Helpers
else // Otherwise, delete the file.
File.Delete(logFile);
}
/// <summary>
/// Checks if we currently have an internet connection, by pinging github.
/// </summary>
/// <returns><see langword="true"/> if we have internet, <see langword="false"/> if not.</returns>
public static bool IsConnectedToInternet()
{
log.Info("Checking internet connection...");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://github.com");
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException)
{
log.Info("Internet connection failed.");
return false;
}
log.Info("Internet connection established!");
return true;
}
}
}

@ -1124,28 +1124,5 @@ namespace AM2RLauncher
// if we didn't exit before, everything is fine
return IsZipAM2R11ReturnCodes.Successful;
}
/// <summary>
/// Checks if we currently have an internet connection, by pinging github.
/// </summary>
/// <returns></returns>
private static bool IsConnectedToInternet()
{
log.Info("Checking internet connection...");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://github.com");
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException)
{
log.Info("Internet connection failed.");
return false;
}
log.Info("Internet connection established!");
return true;
}
}
}

@ -101,7 +101,7 @@ namespace AM2RLauncher
/// <summary>
/// Indicates whether or not we have established an internet connection.
/// </summary>
readonly static private bool isInternetThere = IsConnectedToInternet();
readonly static private bool isInternetThere = Helpers.HelperMethods.IsConnectedToInternet();
public MainForm()
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Loading…
Cancel
Save