Esempio n. 1
0
        /// <summary>
        /// Creates and opens a new connection.
        /// </summary>
        /// <param name="endpoint">Connection endpoint.</param>
        /// <returns>Newly created connection in an open state.</returns>
        public static DaoConnection Open(DaoConnectionEnum endpoint)
        {
            DaoConnection connection = new DaoConnection(endpoint);

            connection.Open();
            return(connection);
        }
 /// <summary>
 /// Gets the connection string associated with the given endpoint.
 /// </summary>
 /// <param name="endpoint">Target endpoint.</param>
 /// <returns>Connection string associated with the given endpoint.</returns>
 internal static string GetConnectionString(DaoConnectionEnum endpoint)
 {
     switch (endpoint)
     {
         case DaoConnectionEnum.KanjiDatabase:
             return ConfigurationManager.ConnectionStrings[
                 ConnectionStringHelper.KanjiDatabaseConnectionName].ConnectionString;
         case DaoConnectionEnum.SrsDatabase:
             return ConnectionStringHelper.SrsDatabaseConnectionString;
         default:
             throw new ArgumentException(
                 string.Format("Unknown connection: \"{0}\".", endpoint));
     }
 }
        /// <summary>
        /// Gets the connection string associated with the given endpoint.
        /// </summary>
        /// <param name="endpoint">Target endpoint.</param>
        /// <returns>Connection string associated with the given endpoint.</returns>
        internal static string GetConnectionString(DaoConnectionEnum endpoint)
        {
            switch (endpoint)
            {
            case DaoConnectionEnum.KanjiDatabase:
                return(ConfigurationManager.ConnectionStrings[
                           ConnectionStringHelper.KanjiDatabaseConnectionName].ConnectionString);

            case DaoConnectionEnum.SrsDatabase:
                return(ConnectionStringHelper.SrsDatabaseConnectionString);

            default:
                throw new ArgumentException(
                          string.Format("Unknown connection: \"{0}\".", endpoint));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new database connection set in a closed state.
        /// </summary>
        public DaoConnection(DaoConnectionEnum endpoint)
        {
            _connectionOpenEvent = new ManualResetEvent(false);

            //string connectionName = null;
            switch (endpoint)
            {
                case DaoConnectionEnum.KanjiDatabase:
                    _connection = new SQLiteConnection(
                        ConfigurationManager.ConnectionStrings[
                        ConnectionStringHelper.KanjiDatabaseConnectionName].ConnectionString);
                    break;
                case DaoConnectionEnum.SrsDatabase:
                    _connection = new SQLiteConnection(
                        ConnectionStringHelper.SrsDatabaseConnectionString);
                    break;
                default:
                    throw new ArgumentException(
                        string.Format("Unknown connection: \"{0}\".", endpoint));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new database connection set in a closed state.
        /// </summary>
        public DaoConnection(DaoConnectionEnum endpoint)
        {
            _connectionOpenEvent = new ManualResetEvent(false);

            //string connectionName = null;
            switch (endpoint)
            {
            case DaoConnectionEnum.KanjiDatabase:
                _connection = new SQLiteConnection(
                    ConfigurationManager.ConnectionStrings[
                        ConnectionStringHelper.KanjiDatabaseConnectionName].ConnectionString);
                break;

            case DaoConnectionEnum.SrsDatabase:
                _connection = new SQLiteConnection(
                    ConnectionStringHelper.SrsDatabaseConnectionString);
                break;

            default:
                throw new ArgumentException(
                          string.Format("Unknown connection: \"{0}\".", endpoint));
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Creates and opens a new connection.
 /// </summary>
 /// <param name="endpoint">Connection endpoint.</param>
 /// <returns>Newly created connection in an open state.</returns>
 public static DaoConnection Open(DaoConnectionEnum endpoint)
 {
     DaoConnection connection = new DaoConnection(endpoint);
     connection.Open();
     return connection;
 }