internal override Realm CreateRealm(RealmSchema schema) { if (IsPartial) { schema = RealmSchema.CreateSchemaForClasses(QueryBasedSyncConfiguration._queryBasedPermissionTypes, schema); } return(base.CreateRealm(schema)); }
internal override async Task <Realm> CreateRealmAsync(RealmSchema schema, CancellationToken cancellationToken) { var configuration = CreateNativeConfiguration(); var syncConfiguration = CreateNativeSyncConfiguration(); var tcs = new TaskCompletionSource <ThreadSafeReferenceHandle>(); var tcsHandle = GCHandle.Alloc(tcs); ProgressNotificationToken progressToken = null; try { using var handle = SharedRealmHandle.OpenWithSyncAsync(configuration, syncConfiguration, schema, EncryptionKey, tcsHandle); cancellationToken.Register(() => { if (!handle.IsClosed) { handle.Cancel(); tcs.TrySetCanceled(); } }); if (OnProgress != null) { progressToken = new ProgressNotificationToken( observer: (progress) => { OnProgress(progress); }, register: handle.RegisterProgressNotifier, unregister: (token) => { if (!handle.IsClosed) { handle.UnregisterProgressNotifier(token); } }); } using var realmReference = await tcs.Task; var realmPtr = SharedRealmHandle.ResolveFromReference(realmReference); var sharedRealmHandle = new SharedRealmHandle(realmPtr); if (IsDynamic && !schema.Any()) { sharedRealmHandle.GetSchema(nativeSchema => schema = RealmSchema.CreateFromObjectStoreSchema(nativeSchema)); } return(new Realm(sharedRealmHandle, this, schema)); } finally { tcsHandle.Free(); progressToken?.Dispose(); } }
internal override Realm CreateRealm(RealmSchema schema) { var configuration = new Realms.Native.Configuration { Path = DatabasePath, schema_version = SchemaVersion }; var srHandle = SharedRealmHandleExtensions.OpenWithSync(configuration, ToNative(), schema, EncryptionKey); return(new Realm(srHandle, this, schema)); }
internal override Realm CreateRealm(RealmSchema schema) { var configuration = CreateNativeConfiguration(); var syncConfiguration = CreateNativeSyncConfiguration(); var srHandle = SharedRealmHandle.OpenWithSync(configuration, syncConfiguration, schema, EncryptionKey); if (IsDynamic && !schema.Any()) { srHandle.GetSchema(nativeSchema => schema = RealmSchema.CreateFromObjectStoreSchema(nativeSchema)); } return new Realm(srHandle, this, schema); }
public static SharedRealmHandle OpenWithSync(Realms.Native.Configuration configuration, Native.SyncConfiguration syncConfiguration, RealmSchema schema, byte[] encryptionKey) { DoInitialFileSystemConfiguration(); var marshaledSchema = new SharedRealmHandle.SchemaMarshaler(schema); NativeException nativeException; var result = NativeMethods.open_with_sync(configuration, syncConfiguration, marshaledSchema.Objects, marshaledSchema.Objects.Length, marshaledSchema.Properties, encryptionKey, out nativeException); nativeException.ThrowIfNecessary(); var handle = new SharedRealmHandle(); handle.SetHandle(result); return handle; }
internal override async Task <Realm> CreateRealmAsync(RealmSchema schema) { var session = new Session(SharedRealmHandleExtensions.GetSession(DatabasePath, ToNative(), EncryptionKey)); try { await session.WaitForDownloadAsync(); } finally { session.CloseHandle(); } return(CreateRealm(schema)); }
internal override Realm CreateRealm(RealmSchema schema) { var configuration = new Realms.Native.Configuration { schema_version = SchemaVersion }; var syncConfiguration = new Native.SyncConfiguration { SyncUserHandle = User.Handle, Url = ServerUri.ToString() }; var srHandle = SharedRealmHandleExtensions.OpenWithSync(configuration, syncConfiguration, schema, EncryptionKey); return(new Realm(srHandle, this, schema)); }
internal override Realm CreateRealm(RealmSchema schema) { var configuration = new Realms.Native.Configuration { Path = DatabasePath, schema_version = SchemaVersion }; var syncConfiguration = new Native.SyncConfiguration { SyncUserHandle = User.Handle, Url = ServerUri.ToString() }; var srHandle = SharedRealmHandleExtensions.OpenWithSync(configuration, syncConfiguration, schema, EncryptionKey); return new Realm(srHandle, this, schema); }
internal override Realm CreateRealm(RealmSchema schema) { var configuration = new Realms.Native.Configuration { Path = DatabasePath, schema_version = SchemaVersion, enable_cache = EnableCache }; var srHandle = SharedRealmHandleExtensions.OpenWithSync(configuration, ToNative(), schema, EncryptionKey); if (IsDynamic && !schema.Any()) { srHandle.GetSchema(nativeSchema => schema = RealmSchema.CreateFromObjectStoreSchema(nativeSchema)); } return(new Realm(srHandle, this, schema)); }
internal override Realm CreateRealm(RealmSchema schema) { var configuration = new Realms.Native.Configuration { Path = DatabasePath, schema_version = SchemaVersion }; var syncConfiguration = new Native.SyncConfiguration { SyncUserHandle = User.Handle, Url = ServerUri.ToString(), client_validate_ssl = EnableSSLValidation, }; var srHandle = SharedRealmHandleExtensions.OpenWithSync(configuration, syncConfiguration, schema, EncryptionKey); return(new Realm(srHandle, this, schema)); }
public static void Initialize() { RealmSchema.AddDefaultTypes((IEnumerable <Type>) new Type[36] { typeof(ClassGroupRealm), typeof(EducationTaskRealm), typeof(EmailAddressRealm), typeof(EmployeeRealm), typeof(FormMasterRealm), typeof(PhoneNumberRealm), typeof(TeacherRealm), typeof(UzenetRealm), typeof(PostaladaElemTipusAdatSzotarElemRealm), typeof(PostaladaElemRealm), typeof(CsatolmanyRealm), typeof(CimzettTipusAdatSzotarElemRealm), typeof(CimzettRealm), typeof(TutelaryRealm), typeof(TeacherHomeWorkRealm), typeof(SubjectAverageRealm), typeof(StudentHomeWorkRealm), typeof(StudentRealm), typeof(SettingRealm), typeof(RatingRealm), typeof(ProfileRealm), typeof(TokenInfoRealm), typeof(PushSettingsRealm), typeof(ParsedMessageRealm), typeof(NoteRealm), typeof(LessonRealm), typeof(FeatureToggleSet), typeof(InstituteRealm), typeof(FormTeacherRealm), typeof(ExamRealm), typeof(EventRealm), typeof(EvaluationNatureRealm), typeof(EvaluationRealm), typeof(CredentialRealm), typeof(CacheDataRealm), typeof(AbsenceRealm) }); }
internal SchemaMarshaler(RealmSchema schema) { var properties = new List<Native.SchemaProperty>(); Objects = schema.Select(@object => { var start = properties.Count; properties.AddRange(@object.Select(ForMarshalling)); return new Native.SchemaObject { name = @object.Name, properties_start = start, properties_end = properties.Count }; }).ToArray(); Properties = properties.ToArray(); }
public IntPtr Open(Native.Configuration configuration, RealmSchema schema, byte[] encryptionKey) { var marshaledSchema = new SchemaMarshaler(schema); NativeException nativeException; var result = NativeMethods.open(configuration, marshaledSchema.Objects, marshaledSchema.Objects.Length, marshaledSchema.Properties, encryptionKey, out nativeException); nativeException.ThrowIfNecessary(); return result; }
public static AsyncOpenTaskHandle OpenWithSyncAsync(Configuration configuration, SyncConfiguration syncConfiguration, RealmSchema schema, byte[] encryptionKey, GCHandle tcsHandle) { DoInitialFileSystemConfiguration(); var marshaledSchema = new SharedRealmHandle.SchemaMarshaler(schema); var asyncTaskPtr = NativeMethods.open_with_sync_async(configuration, syncConfiguration, marshaledSchema.Objects, marshaledSchema.Objects.Length, marshaledSchema.Properties, encryptionKey, GCHandle.ToIntPtr(tcsHandle), out var nativeException); nativeException.ThrowIfNecessary(); var asyncTaskHandle = new AsyncOpenTaskHandle(asyncTaskPtr); return(asyncTaskHandle); }
internal override Task <Realm> CreateRealmAsync(RealmSchema schema, CancellationToken cancellationToken) { schema = RealmSchema.CreateSchemaForClasses(_queryBasedPermissionTypes, schema); return(base.CreateRealmAsync(schema, cancellationToken)); }
internal override Realm CreateRealm(RealmSchema schema) { schema = RealmSchema.CreateSchemaForClasses(_queryBasedPermissionTypes, schema); return(base.CreateRealm(schema)); }
private static Dictionary <ObjectSchema, HashSet <ObjectSchema> > GetAdjecencyList(RealmSchema realmSchema) { var resultDictionary = new Dictionary <ObjectSchema, HashSet <ObjectSchema> >(); var type = typeof(ObjectSchema); var fieldType = type.GetField("Type", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); foreach (var objectSchema in realmSchema) { var hashset = new HashSet <ObjectSchema>(); var objectType = fieldType.GetValue(objectSchema) as Type; var backlinks = objectType.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(BacklinkAttribute))); foreach (var property in objectSchema) { if (backlinks.Any(backlink => backlink.Name == property.Name)) { continue; } var existingObjectSchema = realmSchema.SingleOrDefault(obj => obj.Name == property.ObjectType); if (existingObjectSchema != null) { hashset.Add(existingObjectSchema); } } resultDictionary[objectSchema] = hashset; } return(resultDictionary); }
internal override Task <Realm> CreateRealmAsync(RealmSchema schema, CancellationToken cancellationToken) { return(Task.FromResult(CreateRealm(schema))); }
internal abstract Realm CreateRealm(RealmSchema schema);
internal override Realm CreateRealm(RealmSchema schema) { var srHandle = new SharedRealmHandle(); var configuration = new Native.Configuration { Path = DatabasePath, read_only = IsReadOnly, delete_if_migration_needed = ShouldDeleteIfMigrationNeeded, schema_version = SchemaVersion }; Migration migration = null; if (MigrationCallback != null) { migration = new Migration(this, schema); migration.PopulateConfiguration(ref configuration); } var srPtr = IntPtr.Zero; try { srPtr = srHandle.Open(configuration, schema, EncryptionKey); } catch (ManagedExceptionDuringMigrationException) { throw new AggregateException("Exception occurred in a Realm migration callback. See inner exception for more details.", migration?.MigrationException); } srHandle.SetHandle(srPtr); return new Realm(srHandle, this, schema); }
internal Migration(RealmConfiguration configuration, RealmSchema schema) { _configuration = configuration; _schema = schema; }
public static SharedRealmHandle OpenWithSync(Configuration configuration, Native.SyncConfiguration syncConfiguration, RealmSchema schema, byte[] encryptionKey) { DoInitialFileSystemConfiguration(); var marshaledSchema = new SharedRealmHandle.SchemaMarshaler(schema); NativeException nativeException; var result = NativeMethods.open_with_sync(configuration, syncConfiguration, marshaledSchema.Objects, marshaledSchema.Objects.Length, marshaledSchema.Properties, encryptionKey, out nativeException); nativeException.ThrowIfNecessary(); var handle = new SharedRealmHandle(); handle.SetHandle(result); return(handle); }
internal override Task <Realm> CreateRealmAsync(RealmSchema schema) { return(Task.FromResult(CreateRealm(schema))); }