using System.Text;

namespace Beam.Models {
    public class ByteDocument : Document {
        public ByteDocument(string filename, byte[] content, Encoding? encoding = null) : base(filename, encoding) {
            Content = content;
        }

        public ByteDocument(string filename, Memory<byte> content, Encoding? encoding = null) :
            base(filename, encoding) {
            Content = content;
        }

        public Memory<byte> Content { get; set; }
        
        public override byte[] ToBytes() {
            return Content.ToArray();
        }

        public override string ToString() {
            return Encoding.GetString(Content.ToArray());
        }
    }
}
