using System.IO;
using CefSharp;

namespace CefSharpWrap.CustomResource
{
    public class DefaultCustomResourceResolveResult : ICustomResourceResolveResult
    {
        private readonly IBytesProvider _provider;

        public DefaultCustomResourceResolveResult(string fileNameForMine, IBytesProvider provider)
        {
            _provider = provider;
            Mime = ResourceHandler.GetMimeType(Path.GetExtension(fileNameForMine));
        }

        public string Mime { get; }
        public Stream Stream => new MemoryStream(_provider.GetBytes());
        public bool Reuseable => false;
    }
}