using System.Reflection;

namespace RobloxLegacy.Utilities;

public class Resource(string name)
{
    private Stream? GetStream()
    {
        var assembly = Assembly.GetExecutingAssembly();
        return assembly.GetManifestResourceStream($"RobloxLegacy.Resources.{name}");
    }
    
    public byte[]? GetBytes()
    {
        using var stream = GetStream();
        if (stream == null)
            return null;

        using var ms = new MemoryStream();
        stream.CopyTo(ms);
        return ms.ToArray();
    }
}