Exemple #1
0
        public ConfigSvcBase()
        {
            var dir = ConfigConst.PRE_CONFIG_DIR.toPath();

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var connectionString =
                new LiteDB.ConnectionString($"{ConfigConst.PRE_CONFIG_DIR}/{ConfigConst.CONFIG_DB_FILE_NAME}")
            {
                Connection = ConnectionType.Shared
            };

            if (this.LiteDatabase.isNull())
            {
                this.LiteDatabase = new LiteDatabase(connectionString);
            }

            if (this.Collection.isNull())
            {
                this.Collection = LiteDatabase.GetCollection(ConfigConst.DB_NAME);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LiteDbConnectionManager"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="scope">The scope.</param>
        public LiteDbConnectionManager(IConnectionInformation connectionInformation, ICreationScope scope)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => scope, scope);
            _connectionInformation = connectionInformation;

            var builder = new LiteDB.ConnectionString(_connectionInformation.ConnectionString);

            _shared = builder.Connection == ConnectionType.Shared;

            var existingScopeConnection = scope.GetDisposable <LiteDbConnectionManager>();

            if (existingScopeConnection != null)
            {
                _db = existingScopeConnection.GetDatabase().Database;
                _shouldDisposeDirectConnection = false;
            }
            else
            {
                _shouldDisposeDirectConnection = true;
            }
        }
Exemple #3
0
 public static LiteException FileSizeExceeds(long limit)
 {
     return(new LiteException(105, "Database size exceeds limit of {0}", ConnectionString.FormatFileSize(limit)));
 }
Exemple #4
0
 public RecoveryService(ConnectionString connectionString)
 {
     _connectionString = connectionString;
 }
Exemple #5
0
 /// <summary>
 /// Starts LiteDB database using a connection string for file system database
 /// </summary>
 public LiteRepository(ConnectionString connectionString, BsonMapper mapper = null)
 {
     _db = new LiteDB.LiteDatabase(connectionString, mapper);
 }
Exemple #6
0
 public JournalService(ConnectionString connectionString, CacheService cache)
 {
     _connectionString = connectionString;
     _cache            = cache;
 }