Skip to content

Commit

Permalink
Merge branch 'feature/no-poll' into Upstream_master
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister committed Jun 8, 2021
2 parents a6d4ef5 + 7aad017 commit e2f1626
Show file tree
Hide file tree
Showing 19 changed files with 790 additions and 1,114 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"fake-cli": {
"version": "5.19.0",
"version": "5.20.4",
"commands": [
"fake"
]
},
"paket": {
"version": "5.241.2",
"version": "5.257.0",
"commands": [
"paket"
]
Expand Down
651 changes: 134 additions & 517 deletions paket.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Deploy/ServiceBouncer.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>ServiceBouncer</id>
<version>1.2.10</version>
<version>1.3.0</version>
<title>ServiceBouncer</title>
<authors>ServiceBouncer</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,16 @@ public class SortableBindingList<T> : BindingList<T> where T : class
private bool isSorted;
private ListSortDirection sortDirection = ListSortDirection.Ascending;
private PropertyDescriptor sortProperty;

public SortableBindingList()
{
}


public SortableBindingList(IList<T> list)
: base(list)
{
}

protected override bool SupportsSortingCore
{
get { return true; }
}

protected override bool IsSortedCore
{
get { return isSorted; }
}

protected override ListSortDirection SortDirectionCore
{
get { return sortDirection; }
}

protected override PropertyDescriptor SortPropertyCore
{
get { return sortProperty; }
}
protected override bool SupportsSortingCore => true;
protected override bool IsSortedCore => isSorted;
protected override ListSortDirection SortDirectionCore => sortDirection;
protected override PropertyDescriptor SortPropertyCore => sortProperty;

protected override void RemoveSortCore()
{
Expand All @@ -51,8 +32,7 @@ protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection
sortProperty = prop;
sortDirection = direction;

var list = Items as List<T>;
if (list == null)
if (!(Items is List<T> list))
{
return;
}
Expand Down Expand Up @@ -90,8 +70,7 @@ private int OnComparison(T x, T y)
return 1;
}

var value = xValue as IComparable;
if (value != null)
if (xValue is IComparable value)
{
return value.CompareTo(yValue);
}
Expand Down
20 changes: 0 additions & 20 deletions src/ServiceBouncer/Extensions/AssemblyExtensions.cs

This file was deleted.

43 changes: 0 additions & 43 deletions src/ServiceBouncer/Extensions/ServiceControllerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.IO;
using System.Management;
using System.ServiceProcess;
Expand Down Expand Up @@ -78,47 +77,5 @@ public static void SetStartupType(this ServiceController controller, ServiceStar
wmiManagementObject.InvokeMethod("ChangeStartMode", parameters);
}
}

public static string GetDescription(this ServiceController controller)
{
using (var wmiManagementObject = controller.GetNewWmiManagementObject())
{
return wmiManagementObject["Description"]?.ToString();
}
}

public static string GetLogOnAs(this ServiceController controller)
{
using (var wmiManagementObject = controller.GetNewWmiManagementObject())
{
const string localSystemAccountName = "LocalSystem";

var logOnAs = wmiManagementObject["StartName"]?.ToString();
if (string.IsNullOrWhiteSpace(logOnAs) || logOnAs.Equals(localSystemAccountName, StringComparison.OrdinalIgnoreCase))
{
logOnAs = localSystemAccountName;
}

return logOnAs;
}
}

#if NET45
//NET45 PolyFil as controller doesn't have StartType
public static string GetStartupType(this ServiceController controller)
{
using (var wmiManagementObject = controller.GetNewWmiManagementObject())
{
return wmiManagementObject["StartMode"].ToString();
}
}
#elif NET461 || NET471 || NET48

public static string GetStartupType(this ServiceController controller)
{
return controller.StartType.ToString();
}

#endif
}
}
2 changes: 1 addition & 1 deletion src/ServiceBouncer/FrameworkChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void CheckFrameworkValid()
else
{
var releaseKey = Convert.ToInt32(ndpKey.GetValue("Release"));
if (releaseKey < FrameworkChecker.MinReleaseKey)
if (releaseKey < MinReleaseKey)
{
validFramework = false;
}
Expand Down
24 changes: 15 additions & 9 deletions src/ServiceBouncer/InstallationForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ServiceBouncer
{
public partial class InstallationForm : Form
{
private bool m_installationInProgress;
private bool mInstallationInProgress;

public InstallationForm()
{
Expand Down Expand Up @@ -48,13 +48,13 @@ private void btnSelectService_Click(object sender, EventArgs e)

private async void btnInstall_Click(object sender, EventArgs e)
{
if (m_installationInProgress)
if (mInstallationInProgress)
{
MessageBox.Show("One installation is in progress. Please wait until completion.", "One installation is in progress");
return;
}

m_installationInProgress = true;
mInstallationInProgress = true;

Enabled = false;
Refresh();
Expand All @@ -73,9 +73,11 @@ private async void btnInstall_Click(object sender, EventArgs e)
case "Automatic":
startMode = "auto";
break;

case "Manual":
startMode = "demand";
break;

default:
startMode = "disabled";
break;
Expand All @@ -96,11 +98,13 @@ await Task.Run(() =>
{
using (var installationProcess = Process.Start(startInfo))
{
installationProcess.OutputDataReceived += InstallationProcess_OutputDataReceived;
installationProcess.BeginOutputReadLine();
installationProcess.WaitForExit();
if (installationProcess != null)
{
installationProcess.OutputDataReceived += InstallationProcess_OutputDataReceived;
installationProcess.BeginOutputReadLine();
installationProcess.WaitForExit();
}
}

});
}
catch (Exception ex)
Expand All @@ -113,7 +117,7 @@ await Task.Run(() =>
MessageBox.Show(ex.Message, "An error occurred during installation", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

m_installationInProgress = false;
mInstallationInProgress = false;
Enabled = true;
Refresh();
btnInstall.Text = "Install";
Expand All @@ -124,7 +128,9 @@ private void InstallationProcess_OutputDataReceived(object sender, DataReceivedE
lblProcessResult.Invoke(new MethodInvoker(() =>
{
if (string.IsNullOrEmpty(e.Data))
{
return;
}

lblProcessResult.Text += e.Data;
lblProcessResult.ForeColor = lblProcessResult.Text.IndexOf("failed", StringComparison.OrdinalIgnoreCase) > -1 ? Color.Red : Color.Green;
Expand All @@ -134,7 +140,7 @@ private void InstallationProcess_OutputDataReceived(object sender, DataReceivedE

private void InstallationForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (m_installationInProgress)
if (mInstallationInProgress)
{
MessageBox.Show("One installation is in progress. Please wait until completion.", "One installation is in progress");
e.Cancel = true;
Expand Down
31 changes: 17 additions & 14 deletions src/ServiceBouncer/InstallationForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e2f1626

Please sign in to comment.