protected override void ExecuteCore(RazorCodeDocument codeDocument)
        {
            DocumentIntermediateNode documentNode = codeDocument.GetDocumentIntermediateNode();

            NamespaceDeclarationIntermediateNode namespaceDeclaration =
                documentNode.Children.OfType <NamespaceDeclarationIntermediateNode>().Single();

            // Get the current model type, replacing default of dynamic with IDocument
            string modelType = ModelDirective.GetModelType(documentNode);

            modelType = modelType == "dynamic" ? "IDocument" : modelType;

            // Set the base page type and perform default model type substitution here
            ClassDeclarationIntermediateNode classDeclaration =
                namespaceDeclaration.Children.OfType <ClassDeclarationIntermediateNode>().Single();

            classDeclaration.BaseType = _baseType.Replace("<TModel>", "<" + modelType + ">");

            // Add namespaces
            int insertIndex = namespaceDeclaration.Children.IndexOf(
                namespaceDeclaration.Children.OfType <UsingDirectiveIntermediateNode>().First());

            foreach (string ns in _namespaces)
            {
                namespaceDeclaration.Children.Insert(
                    insertIndex,
                    new UsingDirectiveIntermediateNode()
                {
                    Content = ns
                });
            }

            codeDocument.SetDocumentIntermediateNode(documentNode);
        }
    protected override void ExecuteCore(RazorCodeDocument codeDocument)
    {
        var irDocument = codeDocument.GetDocumentIntermediateNode();

        ThrowForMissingDocumentDependency(irDocument);

        foreach (var pass in Passes)
        {
            pass.Execute(codeDocument, irDocument);
        }

        codeDocument.SetDocumentIntermediateNode(irDocument);
    }