Exemplo n.º 1
0
        //
        // internal constructor; inherit from parent
        //
        public HttpCapabilitiesDefaultProvider(HttpCapabilitiesDefaultProvider parent)
        {
            int id = Interlocked.Increment(ref _idCounter);

            // don't do id.ToString() on every request, do it here
            _cacheKeyPrefix = CacheInternal.PrefixHttpCapabilities + id.ToString(CultureInfo.InvariantCulture);

            if (parent == null)
            {
                ClearParent();
            }
            else
            {
                _rule = parent._rule;

                if (parent._variables == null)
                {
                    _variables = null;
                }
                else
                {
                    _variables = new Hashtable(parent._variables);
                }

                _cachetime  = parent._cachetime;
                _resultType = parent._resultType;
            }
            //
            AddDependency(String.Empty);
        }
        private static void ProcessResult(HttpCapabilitiesDefaultProvider capabilitiesEvaluator, XmlNode node)
        {
            bool val = true;

            System.Web.Configuration.HandlerBase.GetAndRemoveBooleanAttribute(node, "inherit", ref val);
            if (!val)
            {
                capabilitiesEvaluator.ClearParent();
            }
            Type    type  = null;
            XmlNode node2 = System.Web.Configuration.HandlerBase.GetAndRemoveTypeAttribute(node, "type", ref type);

            if ((node2 != null) && !type.Equals(capabilitiesEvaluator._resultType))
            {
                System.Web.Configuration.HandlerBase.CheckAssignableType(node2, capabilitiesEvaluator._resultType, type);
                capabilitiesEvaluator._resultType = type;
            }
            int num = 0;

            if (System.Web.Configuration.HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "cacheTime", ref num) != null)
            {
                capabilitiesEvaluator.CacheTime = TimeSpan.FromSeconds((double)num);
            }
            System.Web.Configuration.HandlerBase.CheckForUnrecognizedAttributes(node);
            System.Web.Configuration.HandlerBase.CheckForNonCommentChildNodes(node);
        }
 /// <summary>
 /// Constructs an instance of <cref see="MobileCapabilitiesProvider"/>.
 /// All default values remain the same and are unaltered.
 /// </summary>
 /// <param name="parent"></param>
 public MobileCapabilitiesProvider(HttpCapabilitiesDefaultProvider parent)
     : base(parent)
 {
     EventLog.Debug("Constructing MobileCapabilitiesProvider with parent");
     #if DEBUG
       LogStackTrace();
     #endif
 }
 /// <summary>
 /// Constructs an instance of <cref see="MobileCapabilitiesProvider"/>.
 /// Sets the cache key length to a value of 256 to allow for mobile
 /// useragents that can often be longer than the default 64 characters.
 /// </summary>
 public MobileCapabilitiesProvider(HttpCapabilitiesDefaultProvider parent)
     : base(parent)
 {
     EventLog.Debug("Constructing MobileCapabilitiesProvider - HttpCapabilitiesDefaultProvider");
     #if DEBUG
         LogStackTrace();
     #endif
     _parent = parent;
     base.UserAgentCacheKeyLength = 256; 
 }
 internal virtual string ResolveServerVariable(string varname)
 {
     if ((varname.Length == 0) || (varname == "HTTP_USER_AGENT"))
     {
         return(HttpCapabilitiesDefaultProvider.GetUserAgent(this._request));
     }
     if (this.EvaluateOnlyUserAgent)
     {
         return(string.Empty);
     }
     return(this.ResolveServerVariableWithAssert(varname));
 }
        internal HttpBrowserCapabilities GetHttpBrowserCapabilities(HttpRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            NameValueCollection     headers     = request.Headers;
            HttpBrowserCapabilities browserCaps = new HttpBrowserCapabilities();
            Hashtable hashtable = new Hashtable(180, StringComparer.OrdinalIgnoreCase);

            hashtable[string.Empty]  = HttpCapabilitiesDefaultProvider.GetUserAgent(request);
            browserCaps.Capabilities = hashtable;
            this.ConfigureBrowserCapabilities(headers, browserCaps);
            this.ConfigureCustomCapabilities(headers, browserCaps);
            return(browserCaps);
        }
        public override HttpBrowserCapabilities GetBrowserCapabilities(HttpRequest request) {
            HttpCapabilitiesDefaultProvider defaultProvider = new HttpCapabilitiesDefaultProvider();

            HttpBrowserCapabilities caps = defaultProvider.GetBrowserCapabilities(request);

            if (request.UserAgent.Contains("Silk")) {
                caps.Capabilities["Browser"] = "Silk";
                caps.Capabilities["IsMobileDevice"] = "true";
                caps.Capabilities["MobileDeviceManufacturer"] = "AmazonA";
                caps.Capabilities["MobileDeviceModel"] = "Kindle FireA";
                if (request.UserAgent.Contains("Kindle Fire HD")) {
                    caps.Capabilities["MobileDeviceModel"] = "Kindle Fire HD";
                }
            }
            return caps;
        }
        internal static string GetBrowserCapKey(IDictionary headers, HttpRequest request)
        {
            StringBuilder builder = new StringBuilder();

            foreach (string str in headers.Keys)
            {
                if (str.Length == 0)
                {
                    builder.Append(HttpCapabilitiesDefaultProvider.GetUserAgent(request));
                }
                else
                {
                    builder.Append(request.Headers[str]);
                }
                builder.Append("\n");
            }
            return(builder.ToString());
        }
        internal static string GetBrowserCapKey(IDictionary headers, HttpRequest request)
        {
            StringBuilder sb = new StringBuilder();

            foreach (String key in headers.Keys)
            {
                if (key.Length == 0)
                {
                    sb.Append(HttpCapabilitiesDefaultProvider.GetUserAgent(request));
                }
                else
                {
                    sb.Append(request.Headers[key]);
                }

                sb.Append("\n");
            }

            return(sb.ToString());
        }
 public HttpCapabilitiesDefaultProvider(HttpCapabilitiesDefaultProvider parent)
 {
     this._cacheKeyPrefix = "e" + Interlocked.Increment(ref _idCounter).ToString(CultureInfo.InvariantCulture);
     if (parent == null)
     {
         this.ClearParent();
     }
     else
     {
         this._rule = parent._rule;
         if (parent._variables == null)
         {
             this._variables = null;
         }
         else
         {
             this._variables = new Hashtable(parent._variables);
         }
         this._cachetime = parent._cachetime;
         this._resultType = parent._resultType;
     }
     this.AddDependency(string.Empty);
 }
Exemplo n.º 11
0
 public HttpCapabilitiesDefaultProvider(HttpCapabilitiesDefaultProvider parent)
 {
     this._cacheKeyPrefix = "e" + Interlocked.Increment(ref _idCounter).ToString(CultureInfo.InvariantCulture);
     if (parent == null)
     {
         this.ClearParent();
     }
     else
     {
         this._rule = parent._rule;
         if (parent._variables == null)
         {
             this._variables = null;
         }
         else
         {
             this._variables = new Hashtable(parent._variables);
         }
         this._cachetime  = parent._cachetime;
         this._resultType = parent._resultType;
     }
     this.AddDependency(string.Empty);
 }
Exemplo n.º 12
0
        //
        // Handle the <result> tag
        //
        static void ProcessResult(HttpCapabilitiesDefaultProvider capabilitiesEvaluator, XmlNode node)
        {
            bool inherit = true;

            HandlerBase.GetAndRemoveBooleanAttribute(node, "inherit", ref inherit);
            if (inherit == false)
            {
                capabilitiesEvaluator.ClearParent();
            }

            Type    resultType = null;
            XmlNode attribute  = HandlerBase.GetAndRemoveTypeAttribute(node, "type", ref resultType);

            if (attribute != null)
            {
                if (resultType.Equals(capabilitiesEvaluator._resultType) == false)
                {
                    // be sure the new type is assignable to the parent type
                    HandlerBase.CheckAssignableType(attribute, capabilitiesEvaluator._resultType, resultType);
                    capabilitiesEvaluator._resultType = resultType;
                }
            }

            int cacheTime = 0;

            attribute = HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "cacheTime", ref cacheTime);
            //NOTE: we continue to parse the cacheTime for backwards compat
            // it has never been used.  Customer scenarios don't require this support.
            if (attribute != null)
            {
                capabilitiesEvaluator.CacheTime = TimeSpan.FromSeconds(cacheTime);
            }

            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForNonCommentChildNodes(node);
        }
        //
        // Handle the <result> tag
        //
        static void ProcessResult(HttpCapabilitiesDefaultProvider capabilitiesEvaluator, XmlNode node) {

            bool inherit = true;
            HandlerBase.GetAndRemoveBooleanAttribute(node, "inherit", ref inherit);
            if (inherit == false) {
                capabilitiesEvaluator.ClearParent();
            }

            Type resultType = null;
            XmlNode attribute = HandlerBase.GetAndRemoveTypeAttribute(node, "type", ref resultType);
            if (attribute != null) {
                if (resultType.Equals(capabilitiesEvaluator._resultType) == false) {
                    // be sure the new type is assignable to the parent type
                    HandlerBase.CheckAssignableType(attribute, capabilitiesEvaluator._resultType, resultType);
                    capabilitiesEvaluator._resultType = resultType;
                }
            }

            int cacheTime = 0;
            attribute = HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "cacheTime", ref cacheTime);
            //NOTE: we continue to parse the cacheTime for backwards compat
            // it has never been used.  Customer scenarios don't require this support.
            if (attribute != null) {
                capabilitiesEvaluator.CacheTime = TimeSpan.FromSeconds(cacheTime);
            }

            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForNonCommentChildNodes(node);

        }
Exemplo n.º 14
0
 public HttpCapabilitiesDefaultProvider(HttpCapabilitiesDefaultProvider parent)
 {
     CacheTime  = parent.CacheTime;
     ResultType = parent.ResultType;
     UserAgentCacheKeyLength = parent.UserAgentCacheKeyLength;
 }
        //
        // internal constructor; inherit from parent
        //
        public HttpCapabilitiesDefaultProvider(HttpCapabilitiesDefaultProvider parent) {
            int id = Interlocked.Increment(ref _idCounter);
            // don't do id.ToString() on every request, do it here
            _cacheKeyPrefix = CacheInternal.PrefixHttpCapabilities + id.ToString(CultureInfo.InvariantCulture);

            if (parent == null) {
                ClearParent();
            }
            else {
                _rule = parent._rule;

                if (parent._variables == null)
                    _variables = null;
                else
                    _variables = new Hashtable(parent._variables);

                _cachetime = parent._cachetime;
                _resultType = parent._resultType;
            }
            //
            AddDependency(String.Empty);
        }
		public HttpCapabilitiesDefaultProvider(HttpCapabilitiesDefaultProvider parent)
		{
			CacheTime = parent.CacheTime;
			ResultType = parent.ResultType;
			UserAgentCacheKeyLength = parent.UserAgentCacheKeyLength;
		}