using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace ExtensiblePortfolioSite.SDK.Plugins
{
    internal class UnmanagedLibrary : IPluginUnmanagedLibrary
    {
        private static readonly IReadOnlyList<IPluginLibrary> emptyList = new List<IPluginLibrary>().AsReadOnly();

        public IntPtr LibraryPtr { get; }
        public string Location { get; }

        public IList<IPluginLibrary> Dependents { get; } = new List<IPluginLibrary>();
        public IReadOnlyList<IPluginLibrary> References => emptyList;

        public UnmanagedLibrary(String Location)
        {
            this.Location = Location;
            this.LibraryPtr = NativeLibrary.Load(Location);
        }

        public void Disposing() => NativeLibrary.Free(this.LibraryPtr);
    }
}
