Skip to content

Instantly share code, notes, and snippets.

@ianbattersby
Last active December 12, 2015 02:28
Show Gist options
  • Select an option

  • Save ianbattersby/4698950 to your computer and use it in GitHub Desktop.

Select an option

Save ianbattersby/4698950 to your computer and use it in GitHub Desktop.
Dumping CodeDomUnit
var writer = new StreamWriter(File.Create("c:\\temp\\debug3.txt"));
codeProvider.GenerateCodeFromCompileUnit(razorResult.GeneratedCode, writer, new System.CodeDom.Compiler.CodeGeneratorOptions());
writer.Flush();
writer.WriteLine();
writer.Close();
namespace Simple.Web.Razor.Engine
{
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SimpleRazor
{
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using Simple.Web;
using Simple.Web.Razor;
using Microsoft.CSharp.RuntimeBinder;
public class SimpleView : Simple.Web.Razor.SimpleTemplateModelBase<Simple.Web.Razor.Tests.TestModel>
{
#line hidden
public SimpleView()
{
}
public override void Execute() {
Layout = "~/Views/Layouts/SimpleLayoutWithSections.cshtml";
WriteLiteral("\r\n\r\n<html>\r\n<body>\r\n<p>");
Write(Model.Text);
WriteLiteral("</p>\r\n</body>\r\n</html>\r\n\r\n");
("One", () => {
WriteLiteral("\r\n <p>I am in section one.</p>\r\n");
});
WriteLiteral("\r\n");
("Two", () => {
WriteLiteral("\r\n <p>I am in section two.</p>\r\n");
});
}
}
}
}
this.GeneratedClassContext = new GeneratedClassContext(
executeMethodName: "Execute",
writeMethodName: "Write",
writeLiteralMethodName: "WriteLiteral",
writeToMethodName: "WriteTo",
writeLiteralToMethodName: "WriteLiteralTo",
templateTypeName: null,
defineSectionMethodName: "DefineSection");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment