public static unsafe void Configure(UserPersistenceMode?userPersistenceMode, byte[] encryptionKey, bool resetMetadataOnError, string basePath = null) { // mark the file system as configured in case this is called directly // so that it isn't reconfigured with default values in DoInitialFileSystemConfiguration Interlocked.Exchange(ref _fileSystemConfigured, 1); RealmException.AddOverrider(RealmExceptionCodes.RealmIncompatibleSyncedFile, (message, path) => new IncompatibleSyncedFileException(message, path)); if (basePath == null) { basePath = InteropConfig.DefaultStorageFolder; } UserPersistenceMode mode; UserPersistenceMode *modePtr = null; if (userPersistenceMode.HasValue) { mode = userPersistenceMode.Value; modePtr = &mode; } var userAgent = SyncConfigurationBase.GetSDKUserAgent(); NativeMethods.configure( basePath, (IntPtr)basePath.Length, userAgent, (IntPtr)userAgent.Length, modePtr, encryptionKey, resetMetadataOnError, out var ex); ex.ThrowIfNecessary(); InstallLogCallback(); }
private static unsafe void HandleLogMessage(byte *messageBuffer, IntPtr messageLength, LogLevel level) { try { var message = Encoding.UTF8.GetString(messageBuffer, (int)messageLength); SyncConfigurationBase.CustomLogger?.Invoke(message, level); } catch (Exception ex) { var errorMessage = $"An error occurred while trying to log a message: {ex}"; try { SyncConfigurationBase.CustomLogger(errorMessage, LogLevel.Error); } catch { Console.Error.WriteLine(errorMessage); } } }
public static void ConfigurePersistence(UserPersistenceMode mode, byte[] encryptionKey = null, bool resetOnError = false, string basePath = null) { SyncConfigurationBase.Initialize(mode, encryptionKey, resetOnError, basePath); }