GetMatch() static private method

Returns the match results for the request, or creates one if one does not already exist. If the match has already been calculated it is fetched from the context items collection.
static private GetMatch ( HttpRequest request ) : Match
request System.Web.HttpRequest
return Match
Ejemplo n.º 1
0
        /// <summary>
        /// Gets the JavaScript to send to the specific client device based on the
        /// request context provided.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private static string GetFeatureJavaScript(HttpContext context)
        {
            var queryString = context.Request.QueryString.ToString();
            var match       = WebProvider.GetMatch(context.Request);
            var features    = new List <string>();

            if (String.IsNullOrEmpty(queryString))
            {
                foreach (var property in WebProvider.ActiveProvider.DataSet.Properties.Where(i =>
                                                                                             i._valueType != Entities.Property.PropertyValueType.JavaScript))
                {
                    GetFeatureJavaScript(match, features, property);
                }
            }
            else
            {
                foreach (var propertyName in HttpUtility.UrlDecode(queryString).Split(
                             new char[] { ' ', ',', '&', '|' }))
                {
                    var property = WebProvider.ActiveProvider.DataSet.Properties.FirstOrDefault(i =>
                                                                                                i.Name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase));
                    if (property != null)
                    {
                        GetFeatureJavaScript(match, features, property);
                    }
                }
            }
            return(String.Format("var FODF={{{0}}};", String.Join(",", features.ToArray())));
        }
        /// <summary>
        /// Provides information to the web server about the requesting device.
        /// </summary>
        /// <param name="request">An HttpRequest that provides information about the source device.</param>
        /// <returns>A HttpBrowserCapabilities object containing information relevent to the device
        /// sources from 51Degrees.mobi.</returns>
        public override HttpBrowserCapabilities GetBrowserCapabilities(HttpRequest request)
        {
            var match = WebProvider.GetMatch(request);

            if (match != null)
            {
                // A provider is present so 51Degrees can be used to override
                // some of the returned values.
                return(new FiftyOneBrowserCapabilities(
                           base.GetBrowserCapabilities(request),
                           request,
                           match));
            }
            else
            {
                // No 51Degrees active provider is present so we have to use
                // the base capabilities only.
                return(base.GetBrowserCapabilities(request));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Provides information to the web server about the requesting device.
        /// </summary>
        /// <param name="request">
        /// HttpRequest that provides information about the source device.
        /// </param>
        /// <returns>
        /// A HttpBrowserCapabilities object containing information which
        /// retrieves device data from 51Degrees.
        /// </returns>
        public override HttpBrowserCapabilities GetBrowserCapabilities(HttpRequest request)
        {
            HttpBrowserCapabilities caps;
            var baseCaps = base.GetBrowserCapabilities(request);
            var match    = WebProvider.GetMatch(request);

            if (match != null)
            {
                // A provider is present so 51Degrees can be used to override
                // some of the returned values.
                caps = new FiftyOneBrowserCapabilities(
                    baseCaps,
                    request,
                    match);

                // Copy the adapters from the original.
                var adapters = baseCaps.Adapters.GetEnumerator();
                while (adapters.MoveNext())
                {
                    caps.Adapters.Add(adapters.Key, adapters.Value);
                }

                // Copy the browsers from the original to prevent the Browsers
                // property returning null.
                if (baseCaps.Browsers != null)
                {
                    foreach (string browser in baseCaps.Browsers)
                    {
                        caps.AddBrowser(browser);
                    }
                }
            }
            else
            {
                // No 51Degrees active provider is present so we have to use
                // the base capabilities only.
                caps = baseCaps;
            }
            return(caps);
        }