﻿namespace galaxy.core.config
{
    public class ServerConfigSetting
    {
        public string name { get; }
        public string value { get; set; }

        public ServerConfigSetting(string name, string value = "")
        {
            this.name = name;
            this.value = value;
        }

        public static implicit operator uint(ServerConfigSetting f)
        {
            return uint.TryParse(f.value, out uint temp) ? temp : default(uint);
        }

        public static implicit operator int(ServerConfigSetting f)
        {
            return int.TryParse(f.value, out int temp) ? temp : default(int);
        }

        public static implicit operator string(ServerConfigSetting f)
        {
            return f.value;
        }

        public static implicit operator bool(ServerConfigSetting f)
        {
            var d = f.value.ToLowerInvariant();
            return d == "1" || d == "true";
        }
    }
}
