Beispiel #1
0
 internal Assembly ApplyFallbackResource(Assembly assembly, string releaseName)
 {
     // fall back to SWE if the assembly does not contain the requested resource
     if ((assembly != AssemblyCache.SystemWebExtensions) &&
         !WebResourceUtil.AssemblyContainsWebResource(assembly, releaseName))
     {
         assembly = AssemblyCache.SystemWebExtensions;
     }
     return(assembly);
 }
Beispiel #2
0
        internal bool ShouldUseDebugScript(string releaseName, Assembly assembly,
                                           bool isDebuggingEnabled, Assembly currentAjaxAssembly)
        {
            bool   useDebugScript;
            string debugName = null;

            if (isDebuggingEnabled)
            {
                debugName = GetDebugName(releaseName);

                // If an assembly contains a release script but not a corresponding debug script, and we
                // need to register the debug script, we normally throw an exception.  However, we automatically
                // use the release script if ScriptReference.ScriptMode is Auto.  This improves the developer
                // experience when ScriptMode is Auto, yet still gives the developer full control with the
                // other ScriptModes.
                if (ScriptMode == ScriptMode.Auto && !WebResourceUtil.AssemblyContainsWebResource(assembly, debugName))
                {
                    useDebugScript = false;
                }
                else
                {
                    useDebugScript = true;
                }
            }
            else
            {
                useDebugScript = false;
            }

            // Verify that assembly contains required web resources.  Always check for release
            // script before debug script.
            if (!IsDirectRegistration)
            {
                // Don't check if direct registration, because calls to ScriptManager.RegisterClientScriptResource
                // with resources that do not exist does not throw an exception until the resource is served.
                // This was the existing behavior and matches the behavior with ClientScriptManager.GetWebResourceUrl.
                WebResourceUtil.VerifyAssemblyContainsReleaseWebResource(assembly, releaseName, currentAjaxAssembly);
                if (useDebugScript)
                {
                    Debug.Assert(debugName != null);
                    WebResourceUtil.VerifyAssemblyContainsDebugWebResource(assembly, debugName);
                }
            }

            return(useDebugScript);
        }