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); }
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}"))); }
protected override void CustomSetUp() { base.CustomSetUp(); SyncConfigurationBase.Initialize(UserPersistenceMode.Disabled); _baseFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(NotifierFolder); Directory.CreateDirectory(UserRealmFolder); }
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); }
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(); }
// 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); }