public static void Startup()
        {
            SQLiteConnection connection = null;
            string dbLocation = "expensesDB.db3";

            #if __ANDROID__
              var library = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
              dbLocation = Path.Combine(library, dbLocation);
              var platform = new SQLitePlatformAndroid();
              connection = new SQLiteConnection(platform, dbLocation);

            #elif __IOS__
            CurrentPlatform.Init();
            var docsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var libraryPath = Path.Combine(docsPath, "../Library/");
            dbLocation = Path.Combine(libraryPath, dbLocation);
            var platform = new SQLitePlatformIOS();
            connection = new SQLiteConnection(platform, dbLocation);

            #elif WINDOWS_PHONE
              var platform = new SQLitePlatformWP8();
              dbLocation = Path.Combine(ApplicationData.Current.LocalFolder.Path, dbLocation);
              connection = new SQLiteConnection(platform, dbLocation);
            #endif
            ServiceContainer.Register<IMessageDialog>(() => new MessageDialog());
            ServiceContainer.Register<ICloudService>(AzureService.Instance);
            ServiceContainer.Register<IExpenseService>(() => new ExpenseService(connection));
            ServiceContainer.Register<ExpensesViewModel>();
            ServiceContainer.Register<ExpenseViewModel>();
        }
示例#2
0
        public SQLiteAsyncConnection GetConnection()
        {
            const string sqliteFilename = "Conferences.db3";

            var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename);

            var platform = new SQLitePlatformWP8();

            var connectionWithLock = new SQLiteConnectionWithLock(
                                          platform,
                                          new SQLiteConnectionString(path, true));

            var connection = new SQLiteAsyncConnection(() => connectionWithLock);

            return connection;
        }