Inheritance: Microsoft.AspNet.WebHooks.WebHookStore
        private static IWebHookStore CreateStore()
        {
            var store = new AzureWebHookStore(StorageManager.GetInstance(new TraceLogger()), CommonServices.GetSettings(), new TraceLogger());

            Assert.IsType <AzureWebHookStore>(store);
            return(store);
        }
        /// <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>
        /// <param name="encryptData">Indicates whether the data should be encrypted using <see cref="IDataProtector"/> while persisted.</param>
        public static void InitializeCustomWebHooksAzureStorage(this HttpConfiguration config, bool encryptData)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            WebHooksConfig.Initialize(config);

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

            IStorageManager storageManager = StorageManager.GetInstance(logger);
            IWebHookStore store;
            if (encryptData)
            {
                IDataProtector protector = DataSecurity.GetDataProtector();
                store = new AzureWebHookStore(storageManager, settings, protector, logger);
            }
            else
            {
                store = new AzureWebHookStore(storageManager, settings, logger);
            }
            CustomServices.SetStore(store);
        }
Example #3
0
        /// <summary>
        /// Provides a static method for creating a standalone <see cref="AzureWebHookStore"/> instance.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/> instance to use.</param>
        /// <returns>An initialized <see cref="AzureWebHookStore"/> instance.</returns>
        public static IWebHookStore CreateStore(ILogger logger)
        {
            SettingsDictionary settings       = CommonServices.GetSettings();
            IDataProtector     protector      = DataSecurity.GetDataProtector();
            IStorageManager    storageManager = StorageManager.GetInstance(logger);
            IWebHookStore      store          = new AzureWebHookStore(storageManager, settings, protector, logger);

            return(store);
        }
        public void CreateStore_Succeeds()
        {
            // Arrange
            ILogger logger = new Mock <ILogger>().Object;

            // Act
            IWebHookStore actual = AzureWebHookStore.CreateStore(logger);

            // Assert
            Assert.IsType <AzureWebHookStore>(actual);
        }
Example #5
0
        /// <summary>
        /// Provides a static method for creating a standalone <see cref="AzureWebHookStore"/> instance.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/> instance to use.</param>
        /// <param name="encryptData">Indicates whether the data should be encrypted using <see cref="IDataProtector"/> while persisted.</param>
        /// <returns>An initialized <see cref="AzureWebHookStore"/> instance.</returns>
        public static IWebHookStore CreateStore(ILogger logger, bool encryptData)
        {
            var           settings = CommonServices.GetSettings();
            IWebHookStore store;
            var           storageManager = StorageManager.GetInstance(logger);

            if (encryptData)
            {
                var protector = DataSecurity.GetDataProtector();
                store = new AzureWebHookStore(storageManager, settings, protector, logger);
            }
            else
            {
                store = new AzureWebHookStore(storageManager, settings, logger);
            }
            return(store);
        }
        /// <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 = GetStorageManager(logger);
            IWebHookStore store = new AzureWebHookStore(storageManager, settings, protector, logger);
            CustomServices.SetStore(store);
        }
Example #7
0
 /// <summary>
 /// Provides a static method for creating a standalone <see cref="AzureWebHookStore"/> instance.
 /// </summary>
 /// <param name="logger">The <see cref="ILogger"/> instance to use.</param>
 /// <param name="encryptData">Indicates whether the data should be encrypted using <see cref="IDataProtector"/> while persisted.</param>
 /// <returns>An initialized <see cref="AzureWebHookStore"/> instance.</returns>
 public static IWebHookStore CreateStore(ILogger logger, bool encryptData)
 {
     SettingsDictionary settings = CommonServices.GetSettings();
     IWebHookStore store;
     IStorageManager storageManager = StorageManager.GetInstance(logger);
     if (encryptData)
     {
         IDataProtector protector = DataSecurity.GetDataProtector();
         store = new AzureWebHookStore(storageManager, settings, protector, logger);
     }
     else
     {
         store = new AzureWebHookStore(storageManager, settings, logger);
     }
     return store;
 }