SessionData.cs

47 lines | 1.03 kB Blame History Raw Download
namespace CodeEditorApi
{
    public class SessionData
    {
        public DateTime Timestamp { get; set; }
        public Guid SessionId { get; set; }
        public object Data { get; set; } = default!;
        public DataType Type { get; set; }

        public string FileName
        {
            get
            {
                return SessionId.ToString() + "/" + Helpers.SessionFiles.GetFormattedDate(Timestamp) + FileExtension;
            }
        }

        public string FileExtension { 
            get
            {
                if (Type == DataType.Javascript)
                {
                    return ".js";
                }
                else if (Type == DataType.CSS)
                {
                    return ".css";
                }
                else if (Type == DataType.HTML)
                {
                    return ".html";
                }

                return ".txt";
            }
        }
    }

    public enum DataType
    {
        Javascript,
        HTML,
        CSS,
        Text
    }
}