﻿namespace ExploitFinder
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    using ExploitChecker;

    using global::ExploitFinder.ExtensionNodes;

    using Mono.Addins;
    using Extensibility;

    internal class ExploitFinderManager
    {
      
        static ExploitFinderManager()
        {
            ExtensionManager.Initialize();

        }


        internal IEnumerable<IExploitFinder> GetHostExploitFinders()
        {
            var finders =
                AddinManager.GetExtensionNodes<DnsBlacklistProviderNode>("/ExploitFinder/HostExploitFinder")
                    .Select(
                        e =>
                        new DnsExploitFinder()
                            {
                                ProviderName = e.ProviderName,
                                HostSuffix = e.HostSuffix,
                                ExploitDictionary =
                                    e.ChildNodes
                                    .OfType<ExploitCodeNode>()
                                    .ToDictionary(c => c.Code, c => c.GetExploit())
                            });

            return finders.ToArray();

        }


    }
}
