Skip to content

Commit

Permalink
fix build errors...again
Browse files Browse the repository at this point in the history
  • Loading branch information
MongoCaleb committed Jul 23, 2024
1 parent 52871da commit efaee31
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 24 deletions.
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
23 changes: 2 additions & 21 deletions examples/dotnet/Examples/DataSyncExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DataSyncExamples
Realms.Sync.User user;
FlexibleSyncConfiguration config;

[OneTimeSetUp]

public void Setup()
{
const string myRealmAppId = Config.FSAppId;
Expand All @@ -25,27 +25,8 @@ public void Setup()
config = new FlexibleSyncConfiguration(user);
}

[Test]
public void GetSessionAndState(){
// :snippet-start: get-sync-session
realm = Realm.GetInstance(config);
var session = realm.SyncSession;
// :snippet-end:
// :snippet-start: pause-synced-realm
realm = Realm.GetInstance(config);
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:

}
}
}
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();
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

0 comments on commit efaee31

Please sign in to comment.