예제 #1
0
        void LoadTypeFromSvc(string path, string url, HttpContext context)
        {
            if (CachingCompiler.GetTypeFromCache(path) != null)
            {
                return;
            }

            ServiceHostParser parser = new ServiceHostParser(path, url, context);

            parser.Parse();
            if (parser.Program == null)
            {
                //FIXME: Not caching, as parser.TypeName could be
                //just typename or fully qualified name
                service_type = GetTypeFromBinAndConfig(parser.TypeName);

                /*CachingCompiler.InsertType (
                 *      service_type, service_type.Assembly.Location, url,
                 *      new CacheItemRemovedCallback (RemovedCallback));*/
            }
            else
            {
                service_type = CachingCompiler.CompileAndGetType(
                    parser, url,
                    new CacheItemRemovedCallback(RemovedCallback));
            }

            if (parser.Factory != null)
            {
                factory_type = GetTypeFromBinAndConfig(parser.Factory);

                /*CachingCompiler.InsertType (
                 *      factory_type, factory_type.Assembly.Location, url,
                 *      new CacheItemRemovedCallback (RemovedCallback));*/
            }
        }
        public static Type CompileAndGetType(ServiceHostParser parser,
                                             string key, CacheItemRemovedCallback removed_callback)
        {
            CompilerResults result = CachingCompiler.Compile(parser.Language, key, parser.Program, parser.Filename, parser.Assemblies);

            if (result.NativeCompilerReturnValue != 0)
            {
                throw new CompilationException(parser.Filename, result.Errors, parser.Program);
            }

            Assembly assembly = result.CompiledAssembly;

            if (assembly == null)
            {
                throw new CompilationException(parser.Filename, result.Errors, parser.Program);
            }

            Type type = assembly.GetType(parser.TypeName, true);

            //cache type
            InsertType(type, parser.Filename, key, removed_callback);

            return(type);
        }