public override void GenerateCode(AssemblyBuilder assemblyBuilder)
 {
     if (this.Parser.RequiresCompilation)
     {
         BaseCodeDomTreeGenerator generator = this.CreateCodeDomTreeGenerator(this._parser);
         CodeCompileUnit          ccu       = generator.GetCodeDomTree(assemblyBuilder.CodeDomProvider, assemblyBuilder.StringResourceBuilder, base.VirtualPathObject);
         if (ccu != null)
         {
             if (this._parser.AssemblyDependencies != null)
             {
                 foreach (Assembly assembly in (IEnumerable)this._parser.AssemblyDependencies)
                 {
                     assemblyBuilder.AddAssemblyReference(assembly, ccu);
                 }
             }
             assemblyBuilder.AddCodeCompileUnit(this, ccu);
         }
         this._instantiatableFullTypeName = generator.GetInstantiatableFullTypeName();
         if (this._instantiatableFullTypeName != null)
         {
             assemblyBuilder.GenerateTypeFactory(this._instantiatableFullTypeName);
         }
         this._intermediateFullTypeName = generator.GetIntermediateFullTypeName();
     }
 }
Esempio n. 2
0
        public override void GenerateCode(AssemblyBuilder assemblyBuilder)
        {
            // Don't generate any code for no-compile pages
            if (!Parser.RequiresCompilation)
            {
                return;
            }

            BaseCodeDomTreeGenerator treeGenerator = CreateCodeDomTreeGenerator(_parser);

            CodeCompileUnit ccu = treeGenerator.GetCodeDomTree(assemblyBuilder.CodeDomProvider,
                                                               assemblyBuilder.StringResourceBuilder, VirtualPathObject);

            if (ccu != null)
            {
                // Add all the assemblies
                if (_parser.AssemblyDependencies != null)
                {
                    foreach (Assembly assembly in _parser.AssemblyDependencies)
                    {
                        assemblyBuilder.AddAssemblyReference(assembly, ccu);
                    }
                }

                assemblyBuilder.AddCodeCompileUnit(this, ccu);
            }

            // Get the name of the generated type that can be instantiated.  It may be null
            // in updatable compilation scenarios.
            _instantiatableFullTypeName = treeGenerator.GetInstantiatableFullTypeName();

            // tell the assembly builder to generate a fast factory for this type
            if (_instantiatableFullTypeName != null)
            {
                assemblyBuilder.GenerateTypeFactory(_instantiatableFullTypeName);
            }

            _intermediateFullTypeName = treeGenerator.GetIntermediateFullTypeName();
        }