// Copyright © Selmo Technology GmbH. All Rights Reserved

using System.ComponentModel;

namespace SelmoStudio.Hmi.Server.SelmoHmi.Shared.WellKnownTypes
{
    public enum WellKnownFileFormat
    {
        [Description("text/plain")]
        Text,

        [Description("application/json")]
        Json,

        [Description("text/csv")]
        Csv,

        [Description("application/pdf")]
        Pdf,

        [Description("application/zip")]
        Zip
    }

    public static class WellKnownFileFormatExtension
    {
        public static string GetSymbol(this WellKnownFileFormat unit)
        {
            DescriptionAttribute[] attributes = (DescriptionAttribute[])unit.GetType().GetField(unit.ToString())
                .GetCustomAttributes(typeof(DescriptionAttribute), false);

            return attributes.Length > 0 ? attributes[0].Description : string.Empty;
        }
    }
}