예제 #1
0
        protected override void CustomSetUp()
        {
            base.CustomSetUp();

            var defaultFolder = InteropConfig.DefaultStorageFolder;

            if (TestHelpers.IsWindows)
            {
                // We do this to reduce the length of the folders in Windows
                var testsIndex = defaultFolder.IndexOf("\\Tests\\");
                var docsIndex  = defaultFolder.IndexOf("\\Documents") + 1;

                if (testsIndex > -1 && docsIndex > testsIndex)
                {
                    defaultFolder = Path.Combine(defaultFolder.Substring(0, testsIndex), defaultFolder.Substring(docsIndex))
                                    .Replace("\\Documents", "\\D");

                    Directory.CreateDirectory(defaultFolder);
                }
            }

            if (TestHelpers.IsMacOS)
            {
                // VS for Mac hangs when Realm files are written in a location it doesn't ignore.
                var folder = Path.Combine(Directory.GetCurrentDirectory(), "bin", "Documents");
                Directory.CreateDirectory(folder);
            }

            SyncConfigurationBase.UserAgent = GetType().Name;
            SyncConfigurationBase.Initialize(UserPersistenceMode.NotEncrypted, null, false, defaultFolder);
        }
예제 #2
0
        private async Task <User> GetUser()
        {
            SyncConfigurationBase.Initialize(UserPersistenceMode.NotEncrypted, basePath: Path.GetTempPath());

            return(await Realms.Sync.User.LoginAsync(
                       Credentials.UsernamePassword(realmSettings.Login, realmSettings.Password, createUser: false),
                       new Uri($"https://{realmSettings.RealmServerUrl}")));
        }
예제 #3
0
        protected override void CustomSetUp()
        {
            base.CustomSetUp();

            SyncConfigurationBase.Initialize(UserPersistenceMode.Disabled);
            _baseFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(NotifierFolder);
            Directory.CreateDirectory(UserRealmFolder);
        }
예제 #4
0
        public static async Task <Realm> GetInstanceAsync(SyncConfigurationBase config, bool openAsync, bool waitForRemote = true)
        {
            if (openAsync)
            {
                return(await Realm.GetInstanceAsync(config));
            }

            var realm = Realm.GetInstance(config);

            if (waitForRemote)
            {
                var session = realm.GetSession();
                try
                {
                    await session.WaitForDownloadAsync();
                }
                finally
                {
                    session.CloseHandle();
                }
            }

            return(realm);
        }
예제 #5
0
        public App()
        {
            // workaround for https://github.com/realm/realm-dotnet/issues/1967
            if (Xamarin.Forms.Device.RuntimePlatform != Xamarin.Forms.Device.iOS)
            {
                SyncConfigurationBase.Initialize(UserPersistenceMode.NotEncrypted);
            }

            VersionTracking.Track();

            var language = LanguageService.GetCurrentLanguage();

            AppResources.Culture = new CultureInfo(language.GetLanguageCode());

            if (!IsAppCtorCalled)
            {
                RealmService.InitializeOfflineDatabase();

                IsAppCtorCalled = true;
            }

            this.InitializeComponent();
            this.MainPage = new AppShell();
        }
예제 #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSession();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <CheckFieldHub>("/checkfield");
                endpoints.MapHub <ProgressHub>("/progress");
                endpoints.MapHub <DataListHub>("/datalist");
            });



            //
            var cultureInfo = new CultureInfo("it-IT");

            cultureInfo.NumberFormat.CurrencySymbol     = "€";
            cultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            string root;

            wwwroot = env.WebRootPath;

            var environment   = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            var isDevelopment = environment == EnvironmentName.Development;

            if (isDevelopment)
            {
                root = Path.GetTempPath();
            }
            else
            {
                root = env.WebRootPath;
            }

            Console.WriteLine("PathRealm:" + root);

            SyncConfigurationBase.Initialize(UserPersistenceMode.NotEncrypted, basePath: root);
        }