Formatting + code review

This commit is contained in:
JustArchi
2016-06-28 06:58:59 +02:00
parent 8db29fa5a7
commit 5a8701444a
4 changed files with 48 additions and 69 deletions

View File

@@ -1,32 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics.CodeAnalysis;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace ArchiSteamFarm
{
[RunInstaller(true)]
public sealed class ArchiServiceInstaller : System.Configuration.Install.Installer
{
public ArchiServiceInstaller()
{
ServiceInstaller serviceInstaller = new ServiceInstaller();
ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller();
namespace ArchiSteamFarm {
[RunInstaller(true)]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public sealed class ArchiServiceInstaller : Installer {
public ArchiServiceInstaller() {
ServiceInstaller serviceInstaller = new ServiceInstaller();
ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller();
serviceInstaller.ServiceName = SharedInfo.ServiceName;
serviceInstaller.DisplayName = SharedInfo.ServiceDescription;
serviceInstaller.ServiceName = SharedInfo.ServiceName;
serviceInstaller.DisplayName = SharedInfo.ServiceDescription;
//defaulting to only starting when a user starts it, can be easily changed after install
serviceInstaller.StartType = ServiceStartMode.Manual;
// Defaulting to only starting when a user starts it, can be easily changed after install
serviceInstaller.StartType = ServiceStartMode.Manual;
//system account, requires admin privilege to install
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
// System account, requires admin privilege to install
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
Installers.Add(serviceInstaller);
Installers.Add(serviceProcessInstaller);
}
}
Installers.Add(serviceInstaller);
Installers.Add(serviceProcessInstaller);
}
}
}

View File

@@ -91,7 +91,6 @@
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Security" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceModel" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />

View File

@@ -518,52 +518,37 @@ namespace ArchiSteamFarm {
}
private static void Main(string[] args) {
if (!Environment.UserInteractive)
{
//Running as service
using (var service = new Service())
ServiceBase.Run(service);
}
else
{
//Console app
Init(args);
if (!Environment.UserInteractive) {
// Service
using (Service service = new Service()) {
ServiceBase.Run(service);
}
} else {
// App
Init(args);
// Wait for signal to shutdown
ShutdownResetEvent.Wait();
// Wait for signal to shutdown
ShutdownResetEvent.Wait();
// We got a signal to shutdown
Exit();
}
// We got a signal to shutdown
Exit();
}
}
sealed class Service : ServiceBase
{
public Service()
{
ServiceName = SharedInfo.ServiceName;
}
private sealed class Service : ServiceBase {
internal Service() {
ServiceName = SharedInfo.ServiceName;
}
protected override void OnStart(string[] args)
{
//Services must not block, they have 30 seconds to return from the start method or are killed
new Thread(() =>
{
Init(args);
ShutdownResetEvent.Wait();
Stop();
protected override void OnStart(string[] args) => new Thread(() => {
Init(args);
ShutdownResetEvent.Wait();
Stop();
}).Start();
}).Start();
}
protected override void OnStop()
{
ShutdownResetEvent.Set();
}
}
}
protected override void OnStop() => ShutdownResetEvent.Set();
}
}
}

View File

@@ -24,11 +24,11 @@
namespace ArchiSteamFarm {
internal static class SharedInfo {
internal const string Copyright = "Copyright © ArchiSteamFarm 2015-2016";
internal const string Version = "2.1.1.3";
internal const string Copyright = "Copyright © ArchiSteamFarm 2015-2016";
internal const string GithubRepo = "JustArchi/ArchiSteamFarm";
internal const string ServiceName = "ArchiSteamFarm";
internal const string ServiceDescription = "ASF is an application that allows you to farm steam cards using multiple steam accounts simultaneously.";
internal const string ServiceName = "ArchiSteamFarm";
internal const string ServiceDescription = "ASF is an application that allows you to farm steam cards using multiple steam accounts simultaneously.";
}
}