using System.IO;
using System.Reflection;
using LJLib.Tools.File;

namespace LJLib.InstallHelper
{
    static class LJInstallGlobal
    {
        private const string section = "E0A0E72ECA4D4BEC950A4A3B1E75DC0F";

        public static string CurrentPath
        {
            get
            {
                return Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");

            }
        }

        public static string FileName
        {
            get
            {
                return Path.GetFileName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            }
        }

        public static string XmlFile
        {
            get
            {
                return FileName + ".xml";
            }
        }

        public static void SetValue(string key, string value)
        {
            string xmlfile = CurrentPath + "\\" + XmlFile;
            XmlConfig xmlconfig = new XmlConfig();
            xmlconfig.SetXmlFileValue(xmlfile, section, key, value);
        }

        public static string GetValue(string key)
        {
            string xmlfile = CurrentPath + "\\" + XmlFile;
            XmlConfig xmlconfig = new XmlConfig();
            return xmlconfig.GetXmlFileValue(xmlfile, section, key, string.Empty);
        }

        public static string ServerName
        {
            get
            {
                return GetValue("ServerName");
            }
            set
            {
                SetValue("ServerName", value);
            }
        }

        public static string DisplayName
        {
            get
            {
                return GetValue("DisplayName");
            }
            set
            {
                SetValue("DisplayName", value);
            }
        }

        public static string Description
        {
            get
            {
                return GetValue("Description");
            }
            set
            {
                SetValue("Description", value);
            }
        }

        public static string ImagePath
        {
            get
            {
                return GetValue("ImagePath");
            }
            set
            {
                SetValue("ImagePath", value);
            }
        }
    }
}
