コード例 #1
0
        private async Task InitializeDb()
        {
            StorageService storageService = new StorageService();
            string         path           = storageService.GetPathForFileAsync("SalesApp.db3");

            ISQLitePlatform sqLitePlatform = new SQLitePlatformGeneric();
            await DatabaseInstance.Instance.InitializeDb(sqLitePlatform, path);
        }
コード例 #2
0
        public static SQLiteConnection GetConnection(string name)
        {
            ISQLitePlatform platform = new SQLitePlatformGeneric();

            if (!Connections.ContainsKey(name))
            {
                Connections[name] = new SQLiteConnection(platform, DbFileNames[name]);
            }

            return(Connections[name]);
        }
コード例 #3
0
        public override SQLiteConnection GetDatabase(string name)
        {
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32();
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, @":memory:"));
        }
コード例 #4
0
        public override SQLiteConnection GetDatabase(string name)
        {
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32(Architecture.NativeIncludePath);
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, GetUsablePathFor($@"{name}.db", true)));
        }
コード例 #5
0
        public override SQLiteConnection GetDatabase(string name)
        {
            Directory.CreateDirectory(BasePath);
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32();
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, Path.Combine(BasePath, $@"{name}.db")));
        }
コード例 #6
0
ファイル: DesktopStorage.cs プロジェクト: guusw/osu-framework
        public override SQLiteConnection GetDatabase(string name, SQLiteOpenFlags openFlags = SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create,
                                                     bool storeDateTimeAsTicks = true, IBlobSerializer serializer = null,
                                                     IDictionary <string, TableMapping> tableMappings = null,
                                                     IDictionary <Type, string> extraTypeMappings     = null, IContractResolver resolver = null)
        {
            Directory.CreateDirectory(BasePath);
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32();
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, Path.Combine(BasePath, $@"{name}.db"), openFlags, storeDateTimeAsTicks, serializer, tableMappings, extraTypeMappings, resolver));
        }
コード例 #7
0
        public SQLiteConnection CreateDb(string fileName)
        {
            var platform = new SQLitePlatformGeneric();

            platform.SQLiteApi.Config(ConfigOption.Serialized);

            /*
             * 使用Serialize模式串行地进行数据读取写入.
             * 如果要并行,需要将DatabaseSource的传递变为string
             * 由各个使用到这个数据库的地方自行建立SQLiteConnection
             * (*MultiThread模式下不能让同一个SQLiteConnection同时被多个线程使用)
             */
            var conn = new SQLiteConnection(
                platform
                , fileName);

            conn.CreateTable <DiffData>();
            return(conn);
        }