Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion examples/dotnet/Examples/BundleARealmExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,37 @@ public async Task TestWriteCopySynced()
// Want to know where the copy is?
var locationOfCopy = existingConfig.DatabasePath;
// :snippet-end:

// :snippet-start: get-sync-session
// :replace-start: {
// "terms": {
// "bundledConfig": "config"
// }
// }
// :replace-end:
realm = Realm.GetInstance(bundledConfig);
// :uncomment-start:
// var session = realm.SyncSession;
// :uncomment-end:
// :snippet-end:
// :snippet-start: pause-synced-realm
// :uncomment-start:
// realm = Realm.GetInstance(config);
// :uncomment-end:
session = realm.SyncSession;
session.Stop();
//later...
session.Start();
// :snippet-end:
// :snippet-start: get-session-state
var sessionState = session.State;
if (sessionState == SessionState.Active){
Console.WriteLine("The session is active");
} else {
Console.WriteLine("The session is inactive");
}
// :snippet-end:

}


Expand All @@ -84,6 +115,7 @@ public async Task ExtractAndLoadRealmFile()
// "terms": {
// "Config.AppId": "\"myRealmAppId\""}
// }
// :replace-end:
// If you are using a local realm
var config = RealmConfiguration.DefaultConfiguration;

Expand All @@ -94,7 +126,6 @@ public async Task ExtractAndLoadRealmFile()
// :remove-start:
config.Schema = new[] { typeof(Examples.Models.User) };
// :remove-end:
// :replace-end:

// Extract and copy the realm
if (!File.Exists(config.DatabasePath))
Expand Down
29 changes: 20 additions & 9 deletions examples/dotnet/Examples/DataSyncExamples.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
using Realms;
using System;
using Microsoft.VisualBasic;
using NUnit.Framework;
using NUnit.Framework.Internal;
using Realms;
using Realms.Sync;

namespace Examples
{
public class DataSyncExamples
{
Realm realm;
App app;
Realms.Sync.User user;
FlexibleSyncConfiguration config;

public void TestsCustomSetter()

public void Setup()
{
realm = Realm.GetInstance();
// :snippet-start: pause-synced-realm
var session = realm.SyncSession;
session.Stop();
//later...
session.Start();
// :snippet-end:
const string myRealmAppId = Config.FSAppId;
app = App.Create(myRealmAppId);
user = app.LogInAsync(
Credentials.Anonymous()).Result;

config = new FlexibleSyncConfiguration(user);
}

public void GetSessionAndState(){

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var config = RealmConfiguration.DefaultConfiguration;

// If the realm file is a synced realm
var app = App.Create("myRealmAppId");
var app = App.Create(Config.AppId);
var user = await app.LogInAsync(Credentials.Anonymous());
config = new PartitionSyncConfiguration("myPartition", user);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var sessionState = session.State;
if (sessionState == SessionState.Active){
Console.WriteLine("The session is active");
} else {
Console.WriteLine("The session is inactive");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
realm = Realm.GetInstance(bundledConfig);
var session = realm.SyncSession;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
realm = Realm.GetInstance(config);
session = realm.SyncSession;
session.Stop();
//later...
session.Start();
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var sessionState = session.State;
if (sessionState == SessionState.Active){
Console.WriteLine("The session is active");
} else {
Console.WriteLine("The session is inactive");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
realm = Realm.GetInstance(config);
var session = realm.SyncSession;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var session = realm.SyncSession;
realm = Realm.GetInstance(config);
session = realm.SyncSession;
session.Stop();
//later...
session.Start();
2 changes: 1 addition & 1 deletion source/sdk/dotnet/sync/sync-session.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ method on the paused session, the Sync session resumes.
The following code block demonstrates calling the ``Stop()`` and ``Start()``
methods:

.. literalinclude:: /examples/generated/dotnet/DataSyncExamples.snippet.pause-synced-realm.cs
.. literalinclude:: /examples/generated/dotnet/BundleARealmExamples.snippet.pause-synced-realm.cs
:language: csharp

When to Pause a Sync Session
Expand Down