Massive sanity reorganization of project structure

Overall:
- Removed all 'TG' prefixes on classes and enums
Service:
- TGStationServer => ServerInstance
- TGServerService => Service
- Moved all ServerInstance partial classes to a subfolder
- Moved ChatProvider classes, delegate, and interface to a namespace
- Moved EventID and ChatMessageType to their own .cs files
- Moved SanitizeTopicString to Program
- ServerService.cs => Service.cs
- Fixed ProjectInstaller being in it's own namespace instead of
TGServerService
Interface:
- Moved ExitCode enum to Command class
- Moved all components to a namespace
- Moved all component enums to Enumerations.cs
- DDInteropCallHolder => DreamDaemonBridge
- Move PullRequestInfo and DreamDaemonBridge to their own .cs files
- Changes the type of ChannelFactory cache from Dictionary<Type,
ChannelFactory> to IDictionary<Type, ChannelFactory>
This commit is contained in:
Cyberboss
2017-10-20 14:00:09 -04:00
parent 7b8fa03f5d
commit 3137be7abb
58 changed files with 3274 additions and 3212 deletions
@@ -0,0 +1,65 @@
using System;
using System.Diagnostics;
using System.IO;
namespace TGServerService
{
// Some useful functions for triggering pre action events
partial class ServerInstance
{
const string EventFolder = "EventHandlers/";
string GetPath(string eventName)
{
return string.Format("{0}{1}.bat", EventFolder, eventName);
}
bool EventHandlerExists(string eventName)
{
return File.Exists(GetPath(eventName));
}
bool HandleEvent(string eventName)
{
if (!EventHandlerExists(eventName))
{
// We don't need a handler, so let's just fail silently.
return true;
}
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = GetPath(eventName),
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
};
process.Start();
process.WaitForExit();
var stdout = process.StandardOutput.ReadToEnd();
var stderr = process.StandardError.ReadToEnd();
Service.WriteInfo(
String.Format("Preaction Event: {0} @ {1} ran. Stdout:\n{2}\nStderr:\n{3}", eventName, GetPath(eventName), stdout, stderr),
process.ExitCode == 0 ? EventID.PreactionEvent : EventID.PreactionFail
);
return process.ExitCode == 0 ? true : false;
}
public bool PrecompileHook()
{
return HandleEvent("precompile");
}
public bool PostcompileHook()
{
return HandleEvent("postcompile");
}
}
}