internal override void InitRecursive(Control namingContainer)
        {
            HashCodeCombiner combinedHashCode = new HashCodeCombiner();

            _cacheKey = ComputeNonVaryCacheKey(combinedHashCode);

            // Save the non-varying hash, so we don't need to recalculate it later
            _nonVaryHashCode = combinedHashCode.CombinedHash;

            PartialCachingCacheEntry cacheEntry = null;

            // Check if there is a cache entry for the non-varying key
            object tmpCacheEntry = OutputCache.GetFragment(_cacheKey, _provider);

            if (tmpCacheEntry != null)
            {
                ControlCachedVary cachedVary = tmpCacheEntry as ControlCachedVary;
                if (cachedVary != null)
                {
                    string varyCachedKey = ComputeVaryCacheKey(combinedHashCode, cachedVary);

                    // Check if there is a cache entry for the varying key
                    cacheEntry = (PartialCachingCacheEntry)OutputCache.GetFragment(varyCachedKey, _provider);
                    if (cacheEntry != null && cacheEntry._cachedVaryId != cachedVary.CachedVaryId)
                    {
                        cacheEntry = null;
                        // explicitly remove the entry
                        OutputCache.RemoveFragment(varyCachedKey, _provider);
                    }
                }
                else
                {
                    // If it wasn't a ControlCachedVary, it must be a PartialCachingCacheEntry
                    cacheEntry = (PartialCachingCacheEntry)tmpCacheEntry;
                }
            }

            // If it's a cache miss, create the control and make it our child
            if (cacheEntry == null)
            {
                // Cache miss

                _cacheEntry = new PartialCachingCacheEntry();

                _cachedCtrl = CreateCachedControl();
                Controls.Add(_cachedCtrl);

                // Make sure the Page knows about us while the control's OnInit is called
                Page.PushCachingControl(this);
                base.InitRecursive(namingContainer);
                Page.PopCachingControl();
            }
            else
            {
                // Cache hit

                _outputString   = cacheEntry.OutputString;
                _cssStyleString = cacheEntry.CssStyleString;

                // If any calls to Register* API's were made when the control was run,
                // make them now to restore correct behavior (VSWhidbey 80907)
                if (cacheEntry.RegisteredClientCalls != null)
                {
                    foreach (RegisterCallData registerCallData in cacheEntry.RegisteredClientCalls)
                    {
                        switch (registerCallData.Type)
                        {
                        case ClientAPIRegisterType.WebFormsScript:
                            Page.RegisterWebFormsScript();
                            break;

                        case ClientAPIRegisterType.PostBackScript:
                            Page.RegisterPostBackScript();
                            break;

                        case ClientAPIRegisterType.FocusScript:
                            Page.RegisterFocusScript();
                            break;

                        case ClientAPIRegisterType.ClientScriptBlocks:
                        case ClientAPIRegisterType.ClientScriptBlocksWithoutTags:
                        case ClientAPIRegisterType.ClientStartupScripts:
                        case ClientAPIRegisterType.ClientStartupScriptsWithoutTags:
                            Page.ClientScript.RegisterScriptBlock(registerCallData.Key,
                                                                  registerCallData.StringParam2, registerCallData.Type);
                            break;

                        case ClientAPIRegisterType.OnSubmitStatement:
                            Page.ClientScript.RegisterOnSubmitStatementInternal(registerCallData.Key,
                                                                                registerCallData.StringParam2);
                            break;

                        case ClientAPIRegisterType.ArrayDeclaration:
                            Page.ClientScript.RegisterArrayDeclaration(registerCallData.StringParam1,
                                                                       registerCallData.StringParam2);
                            break;

                        case ClientAPIRegisterType.HiddenField:
                            Page.ClientScript.RegisterHiddenField(registerCallData.StringParam1,
                                                                  registerCallData.StringParam2);
                            break;

                        case ClientAPIRegisterType.ExpandoAttribute:
                            Page.ClientScript.RegisterExpandoAttribute(registerCallData.StringParam1,
                                                                       registerCallData.StringParam2, registerCallData.StringParam3, false);
                            break;

                        case ClientAPIRegisterType.EventValidation:
                            if (_registeredCallDataForEventValidation == null)
                            {
                                _registeredCallDataForEventValidation = new ArrayList();
                            }

                            _registeredCallDataForEventValidation.Add(registerCallData);
                            break;

                        default:
                            Debug.Assert(false);
                            break;
                        }
                    }
                }

                base.InitRecursive(namingContainer);
            }
        }
        // insert fragment
        internal static void InsertFragment(String cachedVaryKey, ControlCachedVary cachedVary,
                                            String fragmentKey, PartialCachingCacheEntry fragment,
                                            CacheDependency dependencies,
                                            DateTime absExp, TimeSpan slidingExp,
                                            String providerName) {

            // if providerName is not null, find the provider in the collection.
            // if providerName is null, use default provider.
            // if the default provider is undefined or the fragment can't be inserted in the
            // provider, insert it in the internal cache.
            OutputCacheProvider provider = GetFragmentProvider(providerName);

            //
            // ControlCachedVary and PartialCachingCacheEntry can be serialized
            //

            bool useProvider = (provider != null);
            if (useProvider) {
                bool canUseProvider = (slidingExp == Cache.NoSlidingExpiration
                                       && (dependencies == null || dependencies.IsFileDependency()));
            
                if (useProvider && !canUseProvider) {
                    throw new ProviderException(SR.GetString(SR.Provider_does_not_support_policy_for_fragments, providerName));
                }
            }

#if DBG
            bool cachedVaryPutInCache = (cachedVary != null);
#endif
            if (cachedVary != null) {
                // Add the ControlCachedVary item so that a request will know
                // which varies are needed to issue another request.

                // Use the Add method so that we guarantee we only use
                // a single ControlCachedVary and don't overwrite existing ones.
                ControlCachedVary cachedVaryInCache;
                if (!useProvider) {
                    cachedVaryInCache = OutputCache.UtcAdd(cachedVaryKey, cachedVary);
                }
                else {
                    cachedVaryInCache = (ControlCachedVary) provider.Add(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
                }
                
                if (cachedVaryInCache != null) {
                    if (!cachedVary.Equals(cachedVaryInCache)) {
                        // overwrite existing cached vary
                        if (!useProvider) {
                            HttpRuntime.CacheInternal.UtcInsert(cachedVaryKey, cachedVary);
                        }
                        else {
                            provider.Set(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
                        }
                    }
                    else {
                        cachedVary = cachedVaryInCache;
#if DBG
                        cachedVaryPutInCache = false;
#endif
                    }
                }

                if (!useProvider) {
                    AddCacheKeyToDependencies(ref dependencies, cachedVaryKey);
                }

                // not all caches support cache key dependencies, but we can use a "change number" to associate
                // the ControlCachedVary and the PartialCachingCacheEntry
                fragment._cachedVaryId = cachedVary.CachedVaryId;
            }

            // Now insert into the cache (use cache provider if possible, otherwise use internal cache)
            if (!useProvider) {
                HttpRuntime.CacheInternal.UtcInsert(fragmentKey, fragment,
                                                    dependencies,
                                                    absExp, slidingExp,
                                                    CacheItemPriority.Normal,
                                                    null);
            }
            else {
                string depKey = null;
                if (dependencies != null) {
                    depKey = OUTPUTCACHE_KEYPREFIX_DEPENDENCIES + dependencies.GetUniqueID();
                    fragment._dependenciesKey = depKey;
                    fragment._dependencies = dependencies.GetFileDependencies();
                }                
                provider.Set(fragmentKey, fragment, absExp);
                if (dependencies != null) {
                    // use Add and dispose dependencies if there's already one in the cache
                    Object d = HttpRuntime.CacheInternal.UtcAdd(depKey, new DependencyCacheEntry(fragmentKey, null, provider.Name),
                                                                dependencies,
                                                                absExp, Cache.NoSlidingExpiration,
                                                                CacheItemPriority.Normal, s_dependencyRemovedCallbackForFragment);
                    if (d != null) {
                        dependencies.Dispose();
                    }
                }
            }

#if DBG
            string cachedVaryType = (cachedVaryPutInCache) ? "ControlCachedVary" : "";
            string providerUsed = (useProvider) ? provider.Name : "CacheInternal";
            Debug.Trace("OutputCache", "InsertFragment(" 
                        + cachedVaryKey + ", " 
                        + cachedVaryType + ", " 
                        + fragmentKey + ", PartialCachingCacheEntry, ...) -->"
                        + providerUsed);
#endif
        }
    internal override void InitRecursive(Control namingContainer) {

        HashCodeCombiner combinedHashCode = new HashCodeCombiner();

        _cacheKey = ComputeNonVaryCacheKey(combinedHashCode);

        // Save the non-varying hash, so we don't need to recalculate it later
        _nonVaryHashCode = combinedHashCode.CombinedHash;

        PartialCachingCacheEntry cacheEntry = null;

        // Check if there is a cache entry for the non-varying key
        object tmpCacheEntry = OutputCache.GetFragment(_cacheKey, _provider);

        if (tmpCacheEntry != null) {
            ControlCachedVary cachedVary = tmpCacheEntry as ControlCachedVary;
            if (cachedVary != null) {
                string varyCachedKey = ComputeVaryCacheKey(combinedHashCode, cachedVary);

                // Check if there is a cache entry for the varying key
                cacheEntry = (PartialCachingCacheEntry) OutputCache.GetFragment(varyCachedKey, _provider);
                if (cacheEntry != null && cacheEntry._cachedVaryId != cachedVary.CachedVaryId) {
                    cacheEntry = null;
                    // explicitly remove the entry
                    OutputCache.RemoveFragment(varyCachedKey, _provider);
                }
            }
            else {
                // If it wasn't a ControlCachedVary, it must be a PartialCachingCacheEntry
                cacheEntry = (PartialCachingCacheEntry) tmpCacheEntry;
            }
        }

        // If it's a cache miss, create the control and make it our child
        if (cacheEntry == null) {

            // Cache miss

            _cacheEntry = new PartialCachingCacheEntry();

            _cachedCtrl = CreateCachedControl();
            Controls.Add(_cachedCtrl);

            // Make sure the Page knows about us while the control's OnInit is called
            Page.PushCachingControl(this);
            base.InitRecursive(namingContainer);
            Page.PopCachingControl();
        }
        else {

            // Cache hit

            _outputString = cacheEntry.OutputString;
            _cssStyleString = cacheEntry.CssStyleString;

            // If any calls to Register* API's were made when the control was run,
            // make them now to restore correct behavior (VSWhidbey 80907)
            if (cacheEntry.RegisteredClientCalls != null) {
                foreach (RegisterCallData registerCallData in cacheEntry.RegisteredClientCalls) {
                    switch (registerCallData.Type) {

                        case ClientAPIRegisterType.WebFormsScript:
                            Page.RegisterWebFormsScript();
                            break;

                        case ClientAPIRegisterType.PostBackScript:
                            Page.RegisterPostBackScript();
                            break;

                        case ClientAPIRegisterType.FocusScript:
                            Page.RegisterFocusScript();
                            break;

                        case ClientAPIRegisterType.ClientScriptBlocks:
                        case ClientAPIRegisterType.ClientScriptBlocksWithoutTags:
                        case ClientAPIRegisterType.ClientStartupScripts:
                        case ClientAPIRegisterType.ClientStartupScriptsWithoutTags:
                            Page.ClientScript.RegisterScriptBlock(registerCallData.Key,
                                registerCallData.StringParam2, registerCallData.Type);
                            break;

                        case ClientAPIRegisterType.OnSubmitStatement:
                            Page.ClientScript.RegisterOnSubmitStatementInternal(registerCallData.Key,
                                registerCallData.StringParam2);
                            break;

                        case ClientAPIRegisterType.ArrayDeclaration:
                            Page.ClientScript.RegisterArrayDeclaration(registerCallData.StringParam1,
                                registerCallData.StringParam2);
                            break;

                        case ClientAPIRegisterType.HiddenField:
                            Page.ClientScript.RegisterHiddenField(registerCallData.StringParam1,
                                registerCallData.StringParam2);
                            break;

                        case ClientAPIRegisterType.ExpandoAttribute:
                            Page.ClientScript.RegisterExpandoAttribute(registerCallData.StringParam1,
                                registerCallData.StringParam2, registerCallData.StringParam3, false);
                            break;

                        case ClientAPIRegisterType.EventValidation:
                            if (_registeredCallDataForEventValidation == null) {
                                _registeredCallDataForEventValidation = new ArrayList();
                            }

                            _registeredCallDataForEventValidation.Add(registerCallData);
                            break;
                        default:
                            Debug.Assert(false);
                            break;
                    }
                }
            }

            base.InitRecursive(namingContainer);
        }
    }
 internal static void InsertFragment(string cachedVaryKey, ControlCachedVary cachedVary, string fragmentKey, PartialCachingCacheEntry fragment, CacheDependency dependencies, DateTime absExp, TimeSpan slidingExp, string providerName)
 {
     OutputCacheProvider fragmentProvider = GetFragmentProvider(providerName);
     bool flag = fragmentProvider != null;
     if (flag)
     {
         bool flag2 = (slidingExp == Cache.NoSlidingExpiration) && ((dependencies == null) || dependencies.IsFileDependency());
         if (flag && !flag2)
         {
             throw new ProviderException(System.Web.SR.GetString("Provider_does_not_support_policy_for_fragments", new object[] { providerName }));
         }
     }
     if (cachedVary != null)
     {
         ControlCachedVary vary;
         if (!flag)
         {
             vary = UtcAdd(cachedVaryKey, cachedVary);
         }
         else
         {
             vary = (ControlCachedVary) fragmentProvider.Add(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
         }
         if (vary != null)
         {
             if (!cachedVary.Equals(vary))
             {
                 if (!flag)
                 {
                     HttpRuntime.CacheInternal.UtcInsert(cachedVaryKey, cachedVary);
                 }
                 else
                 {
                     fragmentProvider.Set(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
                 }
             }
             else
             {
                 cachedVary = vary;
             }
         }
         if (!flag)
         {
             AddCacheKeyToDependencies(ref dependencies, cachedVaryKey);
         }
         fragment._cachedVaryId = cachedVary.CachedVaryId;
     }
     if (!flag)
     {
         HttpRuntime.CacheInternal.UtcInsert(fragmentKey, fragment, dependencies, absExp, slidingExp, CacheItemPriority.Normal, null);
     }
     else
     {
         string key = null;
         if (dependencies != null)
         {
             key = "aD" + dependencies.GetUniqueID();
             fragment._dependenciesKey = key;
             fragment._dependencies = dependencies.GetFileDependencies();
         }
         fragmentProvider.Set(fragmentKey, fragment, absExp);
         if ((dependencies != null) && (HttpRuntime.CacheInternal.UtcAdd(key, new DependencyCacheEntry(fragmentKey, null, fragmentProvider.Name), dependencies, absExp, Cache.NoSlidingExpiration, CacheItemPriority.Normal, s_dependencyRemovedCallbackForFragment) != null))
         {
             dependencies.Dispose();
         }
     }
 }
        internal override void InitRecursive(Control namingContainer)
        {
            HashCodeCombiner combinedHashCode = new HashCodeCombiner();

            this._cacheKey        = this.ComputeNonVaryCacheKey(combinedHashCode);
            this._nonVaryHashCode = combinedHashCode.CombinedHash;
            PartialCachingCacheEntry entry = null;
            object fragment = OutputCache.GetFragment(this._cacheKey, this._provider);

            if (fragment != null)
            {
                ControlCachedVary cachedVary = fragment as ControlCachedVary;
                if (cachedVary != null)
                {
                    string key = this.ComputeVaryCacheKey(combinedHashCode, cachedVary);
                    entry = (PartialCachingCacheEntry)OutputCache.GetFragment(key, this._provider);
                    if ((entry != null) && (entry._cachedVaryId != cachedVary.CachedVaryId))
                    {
                        entry = null;
                        OutputCache.RemoveFragment(key, this._provider);
                    }
                }
                else
                {
                    entry = (PartialCachingCacheEntry)fragment;
                }
            }
            if (entry == null)
            {
                this._cacheEntry = new PartialCachingCacheEntry();
                this._cachedCtrl = this.CreateCachedControl();
                this.Controls.Add(this._cachedCtrl);
                this.Page.PushCachingControl(this);
                base.InitRecursive(namingContainer);
                this.Page.PopCachingControl();
            }
            else
            {
                this._outputString   = entry.OutputString;
                this._cssStyleString = entry.CssStyleString;
                if (entry.RegisteredClientCalls != null)
                {
                    foreach (RegisterCallData data in entry.RegisteredClientCalls)
                    {
                        switch (data.Type)
                        {
                        case ClientAPIRegisterType.WebFormsScript:
                            this.Page.RegisterWebFormsScript();
                            break;

                        case ClientAPIRegisterType.PostBackScript:
                            this.Page.RegisterPostBackScript();
                            break;

                        case ClientAPIRegisterType.FocusScript:
                            this.Page.RegisterFocusScript();
                            break;

                        case ClientAPIRegisterType.ClientScriptBlocks:
                        case ClientAPIRegisterType.ClientScriptBlocksWithoutTags:
                        case ClientAPIRegisterType.ClientStartupScripts:
                        case ClientAPIRegisterType.ClientStartupScriptsWithoutTags:
                            this.Page.ClientScript.RegisterScriptBlock(data.Key, data.StringParam2, data.Type);
                            break;

                        case ClientAPIRegisterType.OnSubmitStatement:
                            this.Page.ClientScript.RegisterOnSubmitStatementInternal(data.Key, data.StringParam2);
                            break;

                        case ClientAPIRegisterType.ArrayDeclaration:
                            this.Page.ClientScript.RegisterArrayDeclaration(data.StringParam1, data.StringParam2);
                            break;

                        case ClientAPIRegisterType.HiddenField:
                            this.Page.ClientScript.RegisterHiddenField(data.StringParam1, data.StringParam2);
                            break;

                        case ClientAPIRegisterType.ExpandoAttribute:
                            this.Page.ClientScript.RegisterExpandoAttribute(data.StringParam1, data.StringParam2, data.StringParam3, false);
                            break;

                        case ClientAPIRegisterType.EventValidation:
                            if (this._registeredCallDataForEventValidation == null)
                            {
                                this._registeredCallDataForEventValidation = new ArrayList();
                            }
                            this._registeredCallDataForEventValidation.Add(data);
                            break;
                        }
                    }
                }
                base.InitRecursive(namingContainer);
            }
        }
        internal override void InitRecursive(Control namingContainer)
        {
            HashCodeCombiner combinedHashCode = new HashCodeCombiner();
            this._cacheKey = this.ComputeNonVaryCacheKey(combinedHashCode);
            this._nonVaryHashCode = combinedHashCode.CombinedHash;
            PartialCachingCacheEntry entry = null;
            object fragment = OutputCache.GetFragment(this._cacheKey, this._provider);
            if (fragment != null)
            {
                ControlCachedVary cachedVary = fragment as ControlCachedVary;
                if (cachedVary != null)
                {
                    string key = this.ComputeVaryCacheKey(combinedHashCode, cachedVary);
                    entry = (PartialCachingCacheEntry) OutputCache.GetFragment(key, this._provider);
                    if ((entry != null) && (entry._cachedVaryId != cachedVary.CachedVaryId))
                    {
                        entry = null;
                        OutputCache.RemoveFragment(key, this._provider);
                    }
                }
                else
                {
                    entry = (PartialCachingCacheEntry) fragment;
                }
            }
            if (entry == null)
            {
                this._cacheEntry = new PartialCachingCacheEntry();
                this._cachedCtrl = this.CreateCachedControl();
                this.Controls.Add(this._cachedCtrl);
                this.Page.PushCachingControl(this);
                base.InitRecursive(namingContainer);
                this.Page.PopCachingControl();
            }
            else
            {
                this._outputString = entry.OutputString;
                this._cssStyleString = entry.CssStyleString;
                if (entry.RegisteredClientCalls != null)
                {
                    foreach (RegisterCallData data in entry.RegisteredClientCalls)
                    {
                        switch (data.Type)
                        {
                            case ClientAPIRegisterType.WebFormsScript:
                                this.Page.RegisterWebFormsScript();
                                break;

                            case ClientAPIRegisterType.PostBackScript:
                                this.Page.RegisterPostBackScript();
                                break;

                            case ClientAPIRegisterType.FocusScript:
                                this.Page.RegisterFocusScript();
                                break;

                            case ClientAPIRegisterType.ClientScriptBlocks:
                            case ClientAPIRegisterType.ClientScriptBlocksWithoutTags:
                            case ClientAPIRegisterType.ClientStartupScripts:
                            case ClientAPIRegisterType.ClientStartupScriptsWithoutTags:
                                this.Page.ClientScript.RegisterScriptBlock(data.Key, data.StringParam2, data.Type);
                                break;

                            case ClientAPIRegisterType.OnSubmitStatement:
                                this.Page.ClientScript.RegisterOnSubmitStatementInternal(data.Key, data.StringParam2);
                                break;

                            case ClientAPIRegisterType.ArrayDeclaration:
                                this.Page.ClientScript.RegisterArrayDeclaration(data.StringParam1, data.StringParam2);
                                break;

                            case ClientAPIRegisterType.HiddenField:
                                this.Page.ClientScript.RegisterHiddenField(data.StringParam1, data.StringParam2);
                                break;

                            case ClientAPIRegisterType.ExpandoAttribute:
                                this.Page.ClientScript.RegisterExpandoAttribute(data.StringParam1, data.StringParam2, data.StringParam3, false);
                                break;

                            case ClientAPIRegisterType.EventValidation:
                                if (this._registeredCallDataForEventValidation == null)
                                {
                                    this._registeredCallDataForEventValidation = new ArrayList();
                                }
                                this._registeredCallDataForEventValidation.Add(data);
                                break;
                        }
                    }
                }
                base.InitRecursive(namingContainer);
            }
        }