namespace RobotNet.MapShares.Property;

#nullable disable

public class ElementProperty
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public string Type { get; set; }
    public string DefaultValue { get; set; }
    public bool ReadOnly { get; set; }

    private static readonly Dictionary<string, Type> TypeMap = new()
    {
        { "Boolean", typeof(bool) },
        { "Double", typeof(double) },
        { "Int", typeof(int) },
        { "String", typeof(string) },
        { "System.Boolean", typeof(bool) },
        { "System.Double", typeof(double) },
        { "System.Int", typeof(int) },
        { "System.String", typeof(string) },
    };

    public static string GetPropertyTypeName(Type type)
    {
        return TypeMap.FirstOrDefault(kv => kv.Value == type).Key ?? "Unknown";
    }

    public static readonly Type[] PropertyTypes = [
        typeof(bool),
        typeof(double),
        typeof(int),
        typeof(string),
    ];

    public Type GetPropertyType()
    {
        return TypeMap.TryGetValue(Type ?? string.Empty, out var type) ? type : typeof(object);
    }

}
