Esempio n. 1
0
        // -------- Constructor --------

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="databaseLocation">The database location.</param>
        public KarmaBotDatabase(string databaseLocation)
        {
            ISQLitePlatform platform;

            if (Environment.OSVersion.Platform.Equals(PlatformID.Win32NT))
            {
                Console.WriteLine("KarmaBot> Using Win32 Sqlite Platform");
                platform = new SQLite.Net.Platform.Win32.SQLitePlatformWin32();
            }
            else
            {
                // Requires the SQLite.so (shared object) files to be installed.
                Console.WriteLine("KarmaBot> Using Generic Sqlite Platform");
                platform = new SQLite.Net.Platform.Generic.SQLitePlatformGeneric();
            }

            this.sqlite = new SQLiteConnection(
                platform,
                databaseLocation,
                SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite
                );

            this.sqlite.CreateTable <IrcUser>();
            this.sqlite.Commit();

            this.ircUserCache = new Dictionary <string, IrcUser>();
        }
Esempio n. 2
0
        public Db(string dbPath)
        {
            var platform = new SQLite.Net.Platform.Generic.SQLitePlatformGeneric();

            connection = new SQLiteConnection(platform, dbPath);

            CreateDb();
        }
Esempio n. 3
0
        public SQLiteConnection GetConnection()
        {
            if (_connection == null)
            {
                var    folder           = AppDomain.CurrentDomain.BaseDirectory;
                string databaseFileName = Path.Combine(folder, GlobalConfig.DATABASE_NAME);


                var platform = new SQLite.Net.Platform.Generic.SQLitePlatformGeneric();
                _connection = new SQLite.Net.SQLiteConnection(platform, databaseFileName);
            }


            return(_connection);
        }
        protected override void AdditionalSetup()
        {
            _fixture = new Fixture().Customize(new AutoMoqCustomization());

            var mockDeviceInfo = _fixture.InjectNewMock <IDeviceInfo>();

            mockDeviceInfo.Setup(di => di.DatabasePath).Returns(string.Empty);

            var platform = new SQLite.Net.Platform.Generic.SQLitePlatformGeneric();

            _dataService = new DataService(mockDeviceInfo.Object, platform);
            var connection = _dataService.GetDBConnection();

            this.CreateEmptyTable <Device>(connection);
            this.CreateEmptyTable <GrandParentEntity>(connection);
            this.CreateEmptyTable <ParentEntity>(connection);
            this.CreateEmptyTable <ChildEntity>(connection);
            this.CreateEmptyTable <ChildEntity2>(connection);
            this.CreateEmptyTable <SingleChildEntity>(connection);
            this.CreateEmptyTable <MultiChildEntity>(connection);
        }