Exemple #1
0
        private static LocalEseStoreSettings InternalLoadFrom(
            CodePackageActivationContext codePackageActivationContext,
            string configPackageName,
            string sectionName)
        {
            using (var pin = new PinCollection())
            {
                NativeRuntime.IFabricEseLocalStoreSettingsResult nativeResult = NativeRuntime.FabricLoadEseLocalStoreSettings(
                    codePackageActivationContext.NativeActivationContext,
                    pin.AddBlittable(configPackageName),
                    pin.AddBlittable(sectionName));

                return(LocalEseStoreSettings.CreateFromNative(nativeResult));
            }
        }
Exemple #2
0
        private static unsafe LocalEseStoreSettings CreateFromNative(NativeRuntime.IFabricEseLocalStoreSettingsResult nativeResult)
        {
            var managedSettings = new LocalEseStoreSettings();

            var uncastedSettings = nativeResult.get_Settings();

            if (uncastedSettings == IntPtr.Zero)
            {
                return(managedSettings);
            }

            var nativeSettings = (NativeTypes.FABRIC_ESE_LOCAL_STORE_SETTINGS *)uncastedSettings;

            managedSettings.DbFolderPath        = NativeTypes.FromNativeString(nativeSettings->DbFolderPath);
            managedSettings.LogFileSizeInKB     = nativeSettings->LogFileSizeInKB;
            managedSettings.LogBufferSizeInKB   = nativeSettings->LogBufferSizeInKB;
            managedSettings.MaxCursors          = nativeSettings->MaxCursors;
            managedSettings.MaxVerPages         = nativeSettings->MaxVerPages;
            managedSettings.MaxAsyncCommitDelay = TimeSpan.FromMilliseconds(nativeSettings->MaxAsyncCommitDelayInMilliseconds);

            if (nativeSettings->Reserved == IntPtr.Zero)
            {
                return(managedSettings);
            }

            var ex1Settings = (NativeTypes.FABRIC_ESE_LOCAL_STORE_SETTINGS_EX1 *)nativeSettings->Reserved;

            managedSettings.EnableIncrementalBackup = NativeTypes.FromBOOLEAN(ex1Settings->EnableIncrementalBackup);

            if (ex1Settings->Reserved == IntPtr.Zero)
            {
                return(managedSettings);
            }

            var ex2Settings = (NativeTypes.FABRIC_ESE_LOCAL_STORE_SETTINGS_EX2 *)ex1Settings->Reserved;

            managedSettings.MaxCacheSizeInMB = ex2Settings->MaxCacheSizeInMB;

            if (ex2Settings->Reserved == IntPtr.Zero)
            {
                return(managedSettings);
            }

            var ex3Settings = (NativeTypes.FABRIC_ESE_LOCAL_STORE_SETTINGS_EX3 *)ex2Settings->Reserved;

            managedSettings.MaxDefragFrequencyInMinutes = ex3Settings->MaxDefragFrequencyInMinutes;
            managedSettings.DefragThresholdInMB         = ex3Settings->DefragThresholdInMB;
            managedSettings.DatabasePageSizeInKB        = ex3Settings->DatabasePageSizeInKB;

            if (ex3Settings->Reserved == IntPtr.Zero)
            {
                return(managedSettings);
            }

            var ex4Settings = (NativeTypes.FABRIC_ESE_LOCAL_STORE_SETTINGS_EX4 *)ex3Settings->Reserved;

            managedSettings.CompactionThresholdInMB = ex4Settings->CompactionThresholdInMB;

            if (ex4Settings->Reserved == IntPtr.Zero)
            {
                return(managedSettings);
            }

            var ex5Settings = (NativeTypes.FABRIC_ESE_LOCAL_STORE_SETTINGS_EX5 *)ex4Settings->Reserved;

            managedSettings.IntrinsicValueThresholdInBytes = ex5Settings->IntrinsicValueThresholdInBytes;

            if (ex5Settings->Reserved == IntPtr.Zero)
            {
                return(managedSettings);
            }

            var ex6Settings = (NativeTypes.FABRIC_ESE_LOCAL_STORE_SETTINGS_EX6 *)ex5Settings->Reserved;

            managedSettings.EnableOverwriteOnUpdate = NativeTypes.FromBOOLEAN(ex6Settings->EnableOverwriteOnUpdate);

            GC.KeepAlive(nativeResult);

            return(managedSettings);
        }