Пример #1
0
        /// <summary>
        /// load all setting
        /// </summary>
        internal static void LoadSetting()
        {
            BasicConfigLoaded = true;
            string styleXPath    = "/DbConfig/DbStyle";
            string trustedXPath  = "/DbConfig/DbTrusted";
            string hostXPath     = "/DbConfig/DbHost";
            string userXPath     = "/DbConfig/DbUser";
            string passwordXPath = "/DbConfig/DbPassword";
            string portXPath     = "/DbConfig/DbPort";
            string instanceXPath = "/DbConfig/DbInstance";
            string nameXPath     = "/DbConfig/DbName";
            string embedXPath    = "/DbConfig/DbEmbed";
            string positionXPath = "/DbConfig/DbPosition";
            string dbStyle       = XmlTool.GetNodeValueByXPath(styleXPath, _path);

            switch (dbStyle.ToLower())
            {
            case "sqlserver":
                DbStyle = DbStyleDefine.SqlServer;
                break;

            case "oracle":
                DbStyle = DbStyleDefine.Oracle;
                break;

            case "postgres":
                DbStyle = DbStyleDefine.Postgres;
                break;

            case "mysql":
                DbStyle = DbStyleDefine.MySql;
                break;

            case "firebird":
                DbStyle = DbStyleDefine.Firebird;
                break;

            case "sqlite":
                DbStyle = DbStyleDefine.Sqlite;
                break;

            case "access":
                DbStyle = DbStyleDefine.Access;
                break;

            default:
                DbStyle = DbStyleDefine.MySql;
                break;
            }
            DbTrusted  = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(trustedXPath, _path));
            DbHost     = XmlTool.GetNodeValueByXPath(hostXPath, _path);
            DbUser     = XmlTool.GetNodeValueByXPath(userXPath, _path);
            DbPassword = XmlTool.GetNodeValueByXPath(passwordXPath, _path);
            DbPort     = ConvertTool.GetInt(XmlTool.GetNodeValueByXPath(portXPath, _path));
            if (DbPort > 65535)
            {
                DbPort = 65534;
                XmlTool.SetNodeValueByXPath(portXPath, DbPort.ToString(), _path);
            }
            DbInstance = XmlTool.GetNodeValueByXPath(instanceXPath, _path);
            DbName     = XmlTool.GetNodeValueByXPath(nameXPath, _path);
            DbEmbed    = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(embedXPath, _path));
            DbPosition = XmlTool.GetNodeValueByXPath(positionXPath, _path);
        }