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

namespace ExtensiblePortfolioSite.SDK.Plugins
{
    internal interface IPluginLibrary : IDisposable
    {
        String Location { get; }

        public IList<IPluginLibrary> Dependents { get; }
        public IReadOnlyList<IPluginLibrary> References { get; }

        void IDisposable.Dispose()
        {
            IPluginLibrary[] arr = this.Dependents.ToArray();
            foreach(IPluginLibrary dep in arr)
                dep.Dispose();
            this.Dependents.Clear();

            Disposing();

            foreach (IPluginLibrary @ref in this.References)
                @ref.Dependents.Remove(this);
        }
        void Disposing();
    }

    internal interface IPluginManagedLibrary : IPluginLibrary
    {
        Assembly Assembly { get; }
    }
    internal interface IPluginUnmanagedLibrary : IPluginLibrary
    {
        IntPtr LibraryPtr { get; }
    }
}
