示例#1
0
        public static void LoadConnection(Connection connection, string path = null)
        {
            File savedConnection;

            if (path != null && File.Exists(path))
            {
                savedConnection = new File(path);
            }
            else if (GetConnectionConfigFile().Exists())
            {
                savedConnection = GetConnectionConfigFile();
            }
            else
            {
                savedConnection = GetDefaultConnectionConfigFile();
            }

            if (savedConnection.GetSizeInLines() >= 4)
            {
                W3Parser connectionConfiguration = new W3Parser(savedConnection.Path);
                connection.Server   = connectionConfiguration.Get("server")[0];
                connection.User     = connectionConfiguration.Get("user")[0];
                connection.Database = connectionConfiguration.Get("database")[0];
                connection.Password = connectionConfiguration.Get("password")[0];
            }
        }
示例#2
0
        public static bool LoadFromFile(Connection connection, string path)
        {
            bool loaded = false;

            if (path != null && File.Exists(path) && File.GetSizeInLines(path) >= 4)
            {
                W3Parser connectionConfiguration = new W3Parser(path);
                connection.Server   = connectionConfiguration.Get("server")[0];
                connection.User     = connectionConfiguration.Get("user")[0];
                connection.Database = connectionConfiguration.Get("database")[0];
                connection.Password = connectionConfiguration.Get("password")[0];
                loaded = true;
            }
            return(loaded);
        }