Example #1
0
        /// <summary>
        /// Initialize database using any read/write Stream (like MemoryStream)
        /// </summary>
        public LiteDatabase(Stream stream, BsonMapper mapper = null)
        {
            LitePlatform.ThrowIfNotInitialized();

            _mapper = mapper ?? BsonMapper.Global;
            _engine = new LazyLoad <DbEngine>(() => new DbEngine(new StreamDiskService(stream), _log));
        }
Example #2
0
 static LiteDatabase()
 {
     if (LitePlatform.Platform == null)
     {
         LitePlatform.Initialize(new Platform.LitePlatformDotNetStandardDefault());
     }
 }
Example #3
0
        internal EntityBuilder(BsonMapper mapper)
        {
            LitePlatform.ThrowIfNotInitialized();

            _mapper = mapper;
            _prop   = mapper.GetPropertyMapper(typeof(T));
        }
Example #4
0
        /// <summary>
        /// Starts LiteDB database using a connection string for filesystem database
        /// </summary>
        public LiteDatabase(string connectionString, BsonMapper mapper = null)
        {
            LitePlatform.ThrowIfNotInitialized();

            var conn = new ConnectionString(connectionString);

            _mapper = mapper ?? BsonMapper.Global;

            var encrypted = !StringExtensions.IsNullOrWhiteSpace(conn.GetValue <string>("password", null));

            _engine = new LazyLoad <DbEngine>(() => new DbEngine(encrypted ? new EncryptedDiskService(conn, _log) : new FileDiskService(conn, _log), _log));
        }