コード例 #1
0
 /// <summary>
 /// Returns ClientCapability based on the user agent provided.
 /// </summary>
 public override IClientCapability GetClientCapability(string userAgent)
 {
     var request = HttpContext.Current != null ? HttpContext.Current.Request : null;
     if (request != null && request.UserAgent == userAgent &&
         request.Browser.Capabilities.Contains(FiftyOne.Foundation.Mobile.Detection.Constants.FiftyOneDegreesProperties))
     {
         // The useragent has already been processed by 51Degrees.mobi when the request
         // was processed by the detector module. Uses the values obtained then.
         var clientCapability = new FiftyOneClientCapability(request.Browser);
         clientCapability.UserAgent = request.UserAgent;
         return clientCapability;
     }
     else
     {
         // The useragent has not already been processed. Therefore process it now
         // and then set the properties.
         var deviceInfo = Factory.ActiveProvider.GetDeviceInfo(userAgent);
         if (deviceInfo != null)
         {
             return new FiftyOneClientCapability(deviceInfo);
         }
         else
         {
             return new FiftyOneClientCapability(null as SortedList<string, List<string>>);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Returns ClientCapability based on the user agent provided.
        /// </summary>
        public override IClientCapability GetClientCapability(string userAgent)
        {
            var request = HttpContext.Current != null ? HttpContext.Current.Request : null;

            if (request != null && request.UserAgent == userAgent &&
                request.Browser.Capabilities.Contains(Constants.FiftyOneDegreesProperties))
            {
                // The useragent has already been processed by 51Degrees.mobi when the request
                // was processed by the detector module. Uses the values obtained then.
                var clientCapability = new FiftyOneClientCapability(request.Browser)
                {
                    UserAgent = request.UserAgent
                };
                return(clientCapability);
            }
            // The useragent has not already been processed. Therefore process it now
            // and then set the properties.
            var match = WebProvider.ActiveProvider.Match(userAgent);

            if (match != null)
            {
                return(new FiftyOneClientCapability(match));
            }
            return(new FiftyOneClientCapability(null as SortedList <string, string[]>));
        }
コード例 #3
0
 /// <summary>
 /// Returns ClientCapability based on the user agent provided.
 /// </summary>
 public override IClientCapability GetClientCapability(string userAgent)
 {
     var request = HttpContext.Current != null ? HttpContext.Current.Request : null;
     if (request != null && request.UserAgent == userAgent &&
         request.Browser.Capabilities.Contains(Constants.FiftyOneDegreesProperties))
     {
         // The useragent has already been processed by 51Degrees.mobi when the request
         // was processed by the detector module. Uses the values obtained then.
         var clientCapability = new FiftyOneClientCapability(request.Browser) {UserAgent = request.UserAgent};
         return clientCapability;
     }
     // The useragent has not already been processed. Therefore process it now
     // and then set the properties.
     var match = WebProvider.ActiveProvider.Match(userAgent);
     if (match != null)
     {
         return new FiftyOneClientCapability(match);
     }
     return new FiftyOneClientCapability(null as SortedList<string, string[]>);
 }