Inheritance: IStorageManager
Ejemplo n.º 1
0
        /// <summary>
        /// Configures a Microsoft Azure Table Storage implementation of <see cref="IWebHookStore"/>
        /// which provides a persistent store for registered WebHooks used by the custom WebHooks module.
        /// </summary>
        /// <param name="config">The current <see cref="HttpConfiguration"/>config.</param>
        public static void InitializeCustomWebHooksAzureStorage(this HttpConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            WebHooksConfig.Initialize(config);

            ILogger logger = config.DependencyResolver.GetLogger();
            SettingsDictionary settings = config.DependencyResolver.GetSettings();

            IDataProtectionProvider provider = GetDataProtectionProvider();
            IDataProtector protector = provider.CreateProtector(Purpose);

            IStorageManager storageManager = new StorageManager(logger);
            IWebHookStore store = new AzureWebHookStore(storageManager, settings, protector, logger);
            CustomServices.SetStore(store);
        }
        internal static IStorageManager GetStorageManager(ILogger logger)
        {
            if (_storageManager != null)
            {
                return _storageManager;
            }

            IStorageManager instance = new StorageManager(logger);
            Interlocked.CompareExchange(ref _storageManager, instance, null);
            return _storageManager;
        }