Exemplo n.º 1
0
		public SQLiteConnectionWithLock GetConnection (SQLiteConnectionString connectionString)
		{
			lock (_entriesLock) {
				Entry entry;
				string key = connectionString.ConnectionString;

				if (!_entries.TryGetValue (key, out entry)) {
					entry = new Entry (connectionString);
					_entries[key] = entry;
				}

				return entry.Connection;
			}
		}
Exemplo n.º 2
0
        public SQLiteConnectionWithLock GetConnection(SQLiteConnectionString connectionString, SQLiteOpenFlags openFlags)
        {
            lock (_entriesLock) {
                string key = connectionString.ConnectionString;

                if (!_entries.TryGetValue(key, out Entry entry))
                {
                    entry         = new Entry(connectionString, openFlags);
                    _entries[key] = entry;
                }

                return(entry.Connection);
            }
        }
Exemplo n.º 3
0
        public SQLiteConnectionWithLock GetConnection(SQLiteConnectionString connectionString)
        {
            lock (_entriesLock) {
                Entry  entry;
                string key = Thread.CurrentThread.ManagedThreadId + connectionString.ConnectionString;

                if (!_entries.TryGetValue(key, out entry))
                {
                    entry         = new Entry(connectionString);
                    _entries[key] = entry;
                }

                return(entry.Connection);
            }
        }
Exemplo n.º 4
0
        public SQLiteConnectionWithLock GetConnection(SQLiteConnectionString connectionString)
        {
            lock (_entriesLock) {
                Entry  entry;
                string key = connectionString.ConnectionString;

                if (!_entries.TryGetValue(key, out entry))
                {
                    entry          = new Entry(connectionString);
                    _entries [key] = entry;
                }
                //Console.WriteLine("Entries count {0}", _entries.Count);

                return(entry.Connection);
            }
        }
Exemplo n.º 5
0
        static Database()
        {
            var homePath = Environment.GetEnvironmentVariable("HOME");

            if (string.IsNullOrEmpty(homePath))
            {
                homePath = Environment.CurrentDirectory;
            }
            var dbsPath = Path.Combine(homePath, "Databases");

            if (!Directory.Exists(dbsPath))
            {
                Directory.CreateDirectory(dbsPath);
            }
            var dbPath = Path.Combine(dbsPath, "FuGet.sqlite3");

            Console.WriteLine("DATABASE: {0}", dbPath);
            var cs = new SQLite.SQLiteConnectionString(
                dbPath,
                SQLite.SQLiteOpenFlags.Create | SQLite.SQLiteOpenFlags.ReadWrite | SQLite.SQLiteOpenFlags.FullMutex,
                storeDateTimeAsTicks: true);

            ConnectionString = cs;
        }
Exemplo n.º 6
0
 public SQLiteConnectionWithLock(SQLiteConnectionString connectionString)
     : base(connectionString.DatabasePath, connectionString.StoreDateTimeAsTicks)
 {
 }
Exemplo n.º 7
0
 public Entry(SQLiteConnectionString connectionString)
 {
     ConnectionString = connectionString;
     Connection       = new SQLiteConnectionWithLock(connectionString);
 }
Exemplo n.º 8
0
 public SQLiteAsyncConnection(string databasePath, bool storeDateTimeAsTicks = false)
 {
     _connectionString = new SQLiteConnectionString(databasePath, storeDateTimeAsTicks);
 }
Exemplo n.º 9
0
 public Entry(SQLiteConnectionString connectionString, SQLiteOpenFlags openFlags)
 {
     ConnectionString = connectionString;
     Connection       = new SQLiteConnectionWithLock(connectionString, openFlags);
 }
 public SQLiteConnectionWithLock(SQLiteConnectionString connectionString)
     : base(connectionString.DatabasePath)
 {
 }
 public SQLiteAsyncConnection(string connectionString)
 {
     _connectionString = new SQLiteConnectionString(connectionString);
 }
Exemplo n.º 12
0
 public SQLiteConnectionWithLock(SQLiteConnectionString connectionString, SQLiteOpenFlags openFlags)
     : base(connectionString.DatabasePath, openFlags, connectionString.StoreDateTimeAsTicks)
 {
 }
Exemplo n.º 13
0
 public SQLiteAsyncConnection(string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks = true)
 {
     _openFlags        = openFlags;
     _connectionString = new SQLiteConnectionString(databasePath, storeDateTimeAsTicks);
 }
Exemplo n.º 14
0
 public SQLiteAsyncConnection(string databasePath, int maximumNumberOfAttemptsIfBusy = 100, bool storeDateTimeAsTicks = false)
 {
     _maximumNumberOfAttemptsIfBusy = maximumNumberOfAttemptsIfBusy;
     _connectionString = new SQLiteConnectionString(databasePath, storeDateTimeAsTicks);
 }
Exemplo n.º 15
0
 public SQLiteAsyncConnection(string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks = false, bool caseSensitive = true)
 {
     _openFlags        = openFlags;
     _connectionString = new SQLiteConnectionString(databasePath, storeDateTimeAsTicks, caseSensitive);
     _caseSensitive    = caseSensitive;
 }
Exemplo n.º 16
0
 public SQLiteConnectionPool(SQLiteConnectionString connectionString, SQLiteOpenFlags flags, int?connectionCount = null)
 {
     this.connectionCount = connectionCount ?? 4;
     connInfo             = Tuple.Create(connectionString, flags);
     Reset().Wait();
 }