BlackLinks.Templates.InternalCSharpTemplateCompiler.generate C# (CSharp) Method

generate() public method

public generate ( ) : void
return void
		public void generate ()
		{
			parseBLocks ();
#if DEBUG
			foreach (TemplateBlock block in blocks)
			{
				Console.WriteLine ("Block {0} at line {1} = '{2}'",block.Type,block.Line,block.Buffer.ToString());
			}
#endif
			generateAndCompile();
		}
		void generateAndCompile ()

Usage Example

Example #1
0
        protected override TemplatesCompilationResult OnCompile()
        {
            TemplatesCompilationResult result = new TemplatesCompilationResult();

            foreach (var source in this.Sources)
            {
                using (StreamReader reader = new StreamReader(source.SourceStream))
                {
                    InternalCSharpTemplateCompiler compiler = new InternalCSharpTemplateCompiler(reader, ns, source.ReferenceFilePath);
                    compiler.generate();
                    generatedResourcesClassNames.Add(new GeneratedResourceClass
                    {
                        ClassName =
                            compiler.className,
                        DiscoveryPath = source.DiscoveryPath
                    });
                }
            }
            generateDiscoveryClass();
                        #if DEBUG
            using (FileStream fs = new FileStream("/home/thepumpkin/template.cs", FileMode.Create, FileAccess.Write)) {
                using (StreamWriter writer = new StreamWriter(fs)) {
                    csharp.GenerateCodeFromCompileUnit(this.codeCompilerUnit, writer, null);
                }
            }
                        #endif
            string[] assemblies = new string[] { "BlackLinks" };

            CompilerParameters prms = new CompilerParameters(assemblies);
            if (!string.IsNullOrEmpty(this.OutputAssemblyPath))
            {
                prms.OutputAssembly = this.OutputAssemblyPath;
            }
            CompilerResults results = this.csharp.CompileAssemblyFromDom(prms, new CodeCompileUnit[] { this.codeCompilerUnit });

            Console.WriteLine("Errors Count= {0}", results.Errors.Count);
            if (results.CompiledAssembly != null)
            {
                result.Assemblies.Add(results.CompiledAssembly);
            }
                        #if DEBUG
            foreach (CompilerError error in results.Errors)
            {
                Console.Error.WriteLine("\t{0} at file {1}#{2}", error.ErrorText, error.FileName, error.Line);


                result.CompilationErrors.Add(error);
            }
                        #endif
            return(result);
        }
All Usage Examples Of BlackLinks.Templates.InternalCSharpTemplateCompiler::generate