Exemplo n.º 1
0
        public static async Task <List <string> > GenerateDatabase(Realms.Realm targetCache, int size)
        {
            var ret = new List <string>();

            // Write out in groups of 4096
            while (size > 0)
            {
                var toWriteSize = Math.Min(4096, size);
                var toWrite     = GenerateRandomDatabaseContents(toWriteSize);

                await targetCache.WriteAsync(realm =>
                {
                    foreach (var item in toWrite)
                    {
                        var obj   = realm.CreateObject <KeyValueRecord>();
                        obj.Key   = item.Key;
                        obj.Value = item.Value;
                    }
                });

                foreach (var k in toWrite.Keys)
                {
                    ret.Add(k);
                }

                size -= toWrite.Count;
            }
            return(ret);
        }