コード例 #1
0
ファイル: LiteDatabase.cs プロジェクト: zhangxia85/LiteDB
        /// <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));
        }
コード例 #2
0
 static LiteDatabase()
 {
     if (LitePlatform.Platform == null)
     {
         LitePlatform.Initialize(new Platform.LitePlatformDotNetStandardDefault());
     }
 }
コード例 #3
0
        internal EntityBuilder(BsonMapper mapper)
        {
            LitePlatform.ThrowIfNotInitialized();

            _mapper = mapper;
            _prop   = mapper.GetPropertyMapper(typeof(T));
        }
コード例 #4
0
ファイル: LiteDatabase.cs プロジェクト: zhangxia85/LiteDB
        /// <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));
        }