Exemplo n.º 1
0
 internal HttpCachePolicySettings GetCurrentSettings(HttpResponse response)
 {
     string[] allKeys;
     string[] strArray5;
     ValidationCallbackInfo[] infoArray;
     this.UpdateCachedHeaders(response);
     string[] contentEncodings = this._varyByContentEncodings.GetContentEncodings();
     string[] headers          = this._varyByHeaders.GetHeaders();
     string[] @params          = this._varyByParams.GetParams();
     if (this._privateFields != null)
     {
         allKeys = this._privateFields.GetAllKeys();
     }
     else
     {
         allKeys = null;
     }
     if (this._noCacheFields != null)
     {
         strArray5 = this._noCacheFields.GetAllKeys();
     }
     else
     {
         strArray5 = null;
     }
     if (this._validationCallbackInfo != null)
     {
         infoArray = new ValidationCallbackInfo[this._validationCallbackInfo.Count];
         this._validationCallbackInfo.CopyTo(0, infoArray, 0, this._validationCallbackInfo.Count);
     }
     else
     {
         infoArray = null;
     }
     return(new HttpCachePolicySettings(this._isModified, infoArray, this._hasSetCookieHeader, this._noServerCaching, this._cacheExtension, this._noTransforms, this._ignoreRangeRequests, contentEncodings, headers, @params, this._varyByCustom, this._cacheability, this._noStore, allKeys, strArray5, this._utcExpires, this._isExpiresSet, this._maxAge, this._isMaxAgeSet, this._proxyMaxAge, this._isProxyMaxAgeSet, this._slidingExpiration, this._slidingDelta, this._utcTimestampCreated, this._validUntilExpires, this._allowInHistory, this._revalidation, this._utcLastModified, this._isLastModifiedSet, this._etag, this._generateLastModifiedFromFiles, this._generateEtagFromFiles, this._omitVaryStar, this._headerCacheControl, this._headerPragma, this._headerExpires, this._headerLastModified, this._headerEtag, this._headerVaryBy, this._hasUserProvidedDependencies));
 }
        private void OnDeserializedMethod(StreamingContext context) {
            if (_validationCallbackInfoForSerialization == null)
                return;

            // re-create each ValidationCallbackInfo from its string representation
            ValidationCallbackInfo[] callbackInfos = new ValidationCallbackInfo[_validationCallbackInfoForSerialization.Length / 2];
            for (int i = 0; i < _validationCallbackInfoForSerialization.Length; i += 2) {
                string targetTypeName = _validationCallbackInfoForSerialization[i];
                string methodName = _validationCallbackInfoForSerialization[i+1];
                Type target = null;
                if (!String.IsNullOrEmpty(targetTypeName)) {
                    target = BuildManager.GetType(targetTypeName, true /*throwOnFail*/, false /*ignoreCase*/);
                }
                if (target == null) {
                    throw new SerializationException(SR.GetString(SR.Type_cannot_be_resolved, targetTypeName));
                }
                HttpCacheValidateHandler handler = (HttpCacheValidateHandler) Delegate.CreateDelegate(typeof(HttpCacheValidateHandler), target, methodName);
                callbackInfos[i] = new ValidationCallbackInfo(handler, null);
            }
            _validationCallbackInfo = callbackInfos;
        }   
        internal HttpCachePolicySettings(
                bool                        isModified,
                ValidationCallbackInfo[]    validationCallbackInfo,
                bool                        hasSetCookieHeader,
                bool                        noServerCaching,    
                String                      cacheExtension,     
                bool                        noTransforms,       
                bool                        ignoreRangeRequests,
                String[]                    varyByContentEncodings,
                String[]                    varyByHeaderValues, 
                String[]                    varyByParamValues,  
                string                      varyByCustom,       
                HttpCacheability            cacheability,
                bool                        noStore,                
                String[]                    privateFields,          
                String[]                    noCacheFields,          
                DateTime                    utcExpires,                
                bool                        isExpiresSet,           
                TimeSpan                    maxAge,                 
                bool                        isMaxAgeSet,            
                TimeSpan                    proxyMaxAge,            
                bool                        isProxyMaxAgeSet,       
                int                         slidingExpiration,      
                TimeSpan                    slidingDelta,
                DateTime                    utcTimestampCreated,
                int                         validUntilExpires,      
                int                         allowInHistory,
                HttpCacheRevalidation       revalidation,
                DateTime                    utcLastModified,                  
                bool                        isLastModifiedSet,             
                String                      etag,                          
                bool                        generateLastModifiedFromFiles, 
                bool                        generateEtagFromFiles,
                int                         omitVaryStar,
                HttpResponseHeader          headerCacheControl,    
                HttpResponseHeader          headerPragma,          
                HttpResponseHeader          headerExpires,         
                HttpResponseHeader          headerLastModified,    
                HttpResponseHeader          headerEtag,            
                HttpResponseHeader          headerVaryBy,
                bool                        hasUserProvidedDependencies) {

            _isModified                     = isModified                        ;
            _validationCallbackInfo         = validationCallbackInfo            ;

            _hasSetCookieHeader             = hasSetCookieHeader                ;
            _noServerCaching                = noServerCaching                   ;
            _cacheExtension                 = cacheExtension                    ;
            _noTransforms                   = noTransforms                      ;
            _ignoreRangeRequests            = ignoreRangeRequests               ;
            _varyByContentEncodings         = varyByContentEncodings            ;
            _varyByHeaderValues             = varyByHeaderValues                ;
            _varyByParamValues              = varyByParamValues                 ;
            _varyByCustom                   = varyByCustom                      ;
            _cacheability                   = cacheability                      ;
            _noStore                        = noStore                           ;
            _privateFields                  = privateFields                     ;
            _noCacheFields                  = noCacheFields                     ;
            _utcExpires                     = utcExpires                        ;
            _isExpiresSet                   = isExpiresSet                      ;
            _maxAge                         = maxAge                            ;
            _isMaxAgeSet                    = isMaxAgeSet                       ;
            _proxyMaxAge                    = proxyMaxAge                       ;
            _isProxyMaxAgeSet               = isProxyMaxAgeSet                  ;
            _slidingExpiration              = slidingExpiration                 ;
            _slidingDelta                   = slidingDelta                      ;
            _utcTimestampCreated            = utcTimestampCreated               ;
            _validUntilExpires              = validUntilExpires                 ;
            _allowInHistory                 = allowInHistory                    ;
            _revalidation                   = revalidation                      ;
            _utcLastModified                = utcLastModified                   ;
            _isLastModifiedSet              = isLastModifiedSet                 ;
            _etag                           = etag                              ;
            _generateLastModifiedFromFiles  = generateLastModifiedFromFiles     ;
            _generateEtagFromFiles          = generateEtagFromFiles             ;
            _omitVaryStar                   = omitVaryStar                      ;

            _headerCacheControl             = headerCacheControl                ;
            _headerPragma                   = headerPragma                      ;
            _headerExpires                  = headerExpires                     ;
            _headerLastModified             = headerLastModified                ;
            _headerEtag                     = headerEtag                        ;
            _headerVaryBy                   = headerVaryBy                      ;
            _hasUserProvidedDependencies    = hasUserProvidedDependencies       ;

        }
        /*
         * Public methods
         */

        internal HttpCachePolicySettings GetCurrentSettings(HttpResponse response) {
            String[]                    varyByContentEncodings;
            String[]                    varyByHeaders;
            String[]                    varyByParams;
            String[]                    privateFields;
            String[]                    noCacheFields;
            ValidationCallbackInfo[]    validationCallbackInfo;
            
            UpdateCachedHeaders(response);

            varyByContentEncodings = _varyByContentEncodings.GetContentEncodings();
            varyByHeaders = _varyByHeaders.GetHeaders();
            varyByParams = _varyByParams.GetParams();

            if (_privateFields != null) {
                privateFields = _privateFields.GetAllKeys();
            }
            else {
                privateFields = null;
            }

            if (_noCacheFields != null) {
                noCacheFields = _noCacheFields.GetAllKeys();
            }
            else {
                noCacheFields = null;
            }

            if (_validationCallbackInfo != null) {
                validationCallbackInfo = new ValidationCallbackInfo[_validationCallbackInfo.Count];
                _validationCallbackInfo.CopyTo(0, validationCallbackInfo, 0, _validationCallbackInfo.Count);
            }
            else {
                validationCallbackInfo = null;
            }

            return new HttpCachePolicySettings(
                    _isModified,                   
                    validationCallbackInfo,
                    _hasSetCookieHeader,
                    _noServerCaching,   
                    _cacheExtension,             
                    _noTransforms,
                    _ignoreRangeRequests,
                    varyByContentEncodings,
                    varyByHeaders,                  
                    varyByParams,                  
                    _varyByCustom,
                    _cacheability,                 
                    _noStore,
                    privateFields,
                    noCacheFields,               
                    _utcExpires,                      
                    _isExpiresSet,                 
                    _maxAge,                       
                    _isMaxAgeSet,                  
                    _proxyMaxAge,                  
                    _isProxyMaxAgeSet,             
                    _slidingExpiration,            
                    _slidingDelta,
                    _utcTimestampCreated,
                    _validUntilExpires,
                    _allowInHistory,
                    _revalidation,                 
                    _utcLastModified,                 
                    _isLastModifiedSet,            
                    _etag,                         
                    _generateLastModifiedFromFiles,
                    _generateEtagFromFiles,
                    _omitVaryStar,
                    _headerCacheControl, 
                    _headerPragma,       
                    _headerExpires,      
                    _headerLastModified,
                    _headerEtag,
                    _headerVaryBy,
                    _hasUserProvidedDependencies);
        }