using System;
using System.Reflection;
using System.Collections.Generic;

using FilterAPI.Handlers;

namespace FilterTimers.LocalHandlers
{
    internal class LocalHandlerLoader : HandlerLoader
    {
        public LocalHandlerLoader()
        {
            foreach (var PacketHandler in FilterAssembly.FindHandlers<LocalPacketHandler>())
            {
                LocalPacketHandler PacketAttribute = PacketHandler.PacketAttribute;

                MethodInfo PacketMethod = PacketHandler.MethodInfo;

                if (!Handlers.ContainsKey(PacketAttribute.Header)) { Handlers.Add(PacketAttribute.Header, new Dictionary<Byte, MethodInfo>()); }

                if (!Handlers[PacketAttribute.Header].ContainsKey(PacketAttribute.Type)) { Handlers[PacketAttribute.Header].Add(PacketAttribute.Type, PacketMethod); }
            }
        }
    }
}
