/// <summary> /// Determines whether the current browser is a mobile device (by built-in User-Agent sniffing) OR whether it has been configured as /// mobile indicated by the presence of a cookie. /// </summary> /// <remarks> ebrown, 11/10/2010. </remarks> /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception> /// <param name="request"> The incoming request. </param> /// <param name="configuration"> An IMobileConfigurationSection to read settings from. For testing purposes, instances may be faked, /// otherwise use the appropriate xml config and register MobileConfigurationSection from new /// ConfigurationManagerWrapper().GetSection<MobileConfigurationSection> in an IoC container. </param> /// <returns> <c>true</c> if the device is mobile or has been configured as mobile with a cookie; otherwise, <c>false</c>. </returns> public static bool IsMobileDeviceOrConfiguredMobile(this HttpRequestBase request, IMobileConfiguration configuration) { if (null == request) { throw new ArgumentNullException("request"); } if (null == configuration) { throw new ArgumentNullException("configuration"); } var mobileCookie = request.Cookies.Get(configuration.OverrideCookie); return null == mobileCookie ? request.Browser.IsMobileDevice : mobileCookie.Value.ToBoolean(false); }
internal FeatureFlagRequestor(IMobileConfiguration configuration, User user) { this._configuration = configuration; this._httpClient = Util.MakeHttpClient(configuration, MobileClientEnvironment.Instance); this._currentUser = user; }