示例#1
0
        public void SetMobileAppSettingsProvider_Roundtrips()
        {
            // Arrange
            MobileAppSettingsProvider provider = new MobileAppSettingsProvider();
            HttpConfiguration         config   = new HttpConfiguration();

            // Act
            config.SetMobileAppSettingsProvider(provider);
            IMobileAppSettingsProvider actual = config.GetMobileAppSettingsProvider();

            // Assert
            Assert.Same(provider, actual);
        }
示例#2
0
        /// <summary>
        /// Gets the <see cref="Microsoft.Azure.Mobile.Server.Config.IMobileAppSettingsProvider"/> registered with the current <see cref="System.Web.Http.HttpConfiguration" />.
        /// </summary>
        /// <param name="config">The current <see cref="System.Web.Http.HttpConfiguration"/>.</param>
        /// <returns>The registered instance.</returns>
        public static IMobileAppSettingsProvider GetMobileAppSettingsProvider(this HttpConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            IMobileAppSettingsProvider provider = null;

            if (!config.Properties.TryGetValue(MobileAppSettingsProviderKey, out provider))
            {
                provider = new MobileAppSettingsProvider();
                config.Properties[MobileAppSettingsProviderKey] = provider;
            }

            return(provider);
        }