コード例 #1
0
        /*
         * Compile a web handler file into a Type.  Result is cached.
         */
        /// <include file='doc\SimpleWebHandlerParser.uex' path='docs/doc[@for="SimpleWebHandlerParser.GetCompiledTypeFromCache"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected Type GetCompiledTypeFromCache()
        {
            _sourceCompiler = new SourceCompiler(_context, _virtualPath);

            // First, see if it's cached
            Type t = _sourceCompiler.GetTypeFromCache();

            if (t != null)
            {
                return(t);
            }

            CompilationLock.GetLock();

            try {
                // Try the cache again
                t = _sourceCompiler.GetTypeFromCache();
                if (t != null)
                {
                    return(t);
                }

                return(GetCompiledType());
            }
            finally {
                CompilationLock.ReleaseLock();
            }
        }
コード例 #2
0
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            try {
                // Only allowed in full trust (ASURT 124294)
                InternalSecurityPermissions.UnmanagedCode.Demand();

                // If we already got an exception trying to batch this directory, just rethrow it
                Exception e = (Exception)CodeDomBatchManager.BatchErrors[context.Request.BaseDir];
                if (e != null)
                {
                    throw e;
                }

                CompilationLock.GetLock();

                // Allow plenty of time for the batch compilation to complete
                context.Server.ScriptTimeout = 3600;

                PreservedAssemblyEntry.BatchHandlerInit(context);

                CodeDomBatchManager.BatchCompile(context.Request.BaseDir, context);

                // If we get this far and no exception was thrown, it must have worked
                context.Response.Write("<h1>Batch compilation was successful!</h1>");
            }
            finally {
                CompilationLock.ReleaseLock();
            }
        }