Esempio n. 1
0
        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();
        }
        public static unsafe void ConfigureFileSystem(UserPersistenceMode?userPersistenceMode, byte[] encryptionKey, bool resetMetadataOnError)
        {
            // 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);

            var basePath = InteropConfig.DefaultStorageFolder;

            UserPersistenceMode  mode;
            UserPersistenceMode *modePtr = null;

            if (userPersistenceMode.HasValue)
            {
                mode    = userPersistenceMode.Value;
                modePtr = &mode;
            }

            NativeMethods.configure_file_system(basePath, (IntPtr)basePath.Length, modePtr, encryptionKey, resetMetadataOnError, out var ex);
            ex.ThrowIfNecessary();
        }
 public static extern unsafe void configure_file_system([MarshalAs(UnmanagedType.LPWStr)] string base_path, IntPtr base_path_leth,
                                                        UserPersistenceMode *userPersistence, byte[] encryptionKey,
                                                        [MarshalAs(UnmanagedType.I1)] bool resetMetadataOnError,
                                                        out NativeException exception);