Cleaned up several classes

This commit is contained in:
RogueException
2016-01-01 01:06:34 -04:00
parent 321093e0f8
commit c1bee10523
60 changed files with 411 additions and 722 deletions

View File

@@ -6,7 +6,7 @@ using System.Linq;
namespace Discord.Modules
{
public class ModuleManager
public sealed class ModuleManager
{
public event EventHandler<ServerEventArgs> ServerEnabled = delegate { };
public event EventHandler<ServerEventArgs> ServerDisabled = delegate { };

View File

@@ -5,21 +5,19 @@ namespace Discord.Modules
{
public class ModuleService : IService
{
private DiscordClient _client;
//ModuleServiceConfig Config { get; }
public DiscordClient Client { get; private set; }
public IEnumerable<ModuleManager> Modules => _modules.Values;
private readonly Dictionary<IModule, ModuleManager> _modules;
public ModuleService(/*ModuleServiceConfig config*/)
public ModuleService()
{
//Config = config;
_modules = new Dictionary<IModule, ModuleManager>();
}
void IService.Install(DiscordClient client)
{
_client = client;
Client = client;
}
public void Install<T>(T module, string name, FilterType type)
@@ -27,10 +25,12 @@ namespace Discord.Modules
{
if (module == null) throw new ArgumentNullException(nameof(module));
if (name == null) throw new ArgumentNullException(nameof(name));
if (_client == null) throw new InvalidOperationException("Service needs to be added to a DiscordClient before modules can be installed.");
if (_modules.ContainsKey(module)) throw new InvalidOperationException("This module has already been added.");
if (Client == null)
throw new InvalidOperationException("Service needs to be added to a DiscordClient before modules can be installed.");
if (_modules.ContainsKey(module))
throw new InvalidOperationException("This module has already been added.");
var manager = new ModuleManager(_client, name, type);
var manager = new ModuleManager(Client, name, type);
_modules.Add(module, manager);
module.Install(manager);
}