コード例 #1
0
        public async ThreadTask TearDown()
        {
            App app = App.Create(myRealmAppId);

            using (var realm = Realm.GetInstance(config))
            {
                var myTask = new Task()
                {
                    Partition = "foo", Name = "foo2", Status = TaskStatus.Complete.ToString()
                };
                realm.Write(() =>
                {
                    realm.Add(myTask);
                });
                // :code-block-start: delete
                realm.Write(() =>
                {
                    realm.Remove(myTask);
                });
                // :code-block-end:
                realm.Write(() =>
                {
                    realm.RemoveAll <Task>();
                });
                var user = await app.LogInAsync(Credentials.Anonymous());

                // :code-block-start: logout
                await user.LogOutAsync();

                // :code-block-end:
            }
            return;
        }
コード例 #2
0
        public async ThreadTask Setup()
        {
            // :code-block-start: initialize-realm
            app = App.Create(myRealmAppId);
            // :code-block-end:

            user = await app.LogInAsync(
                Credentials.EmailPassword("*****@*****.**", "foobar"));

            config        = new PartitionSyncConfiguration("myPart", user);
            config.Schema = new[]
            {
                typeof(Task),
                typeof(User)
            };

            Realm realm = Realm.GetInstance(config);

            realm.Write(() =>
            {
                realm.RemoveAll <Task>();
            });

            // :code-block-start: open-synced-realm-sync
            // :uncomment-start:
            // var synchronousRealm = await Realm.GetInstanceAsync(config);
            // :uncomment-end:
            // :code-block-end:
            // :code-block-start: create
            var testTask = new Task
            {
                Name      = "Do this thing",
                Status    = TaskStatus.Open.ToString(),
                Partition = "myPart"
            };

            realm.Write(() =>
            {
                realm.Add(testTask);
            });
            // :code-block-end:
            testTaskId = testTask.Id;

            return;
        }