コード例 #1
0
ファイル: MvcRazorHost.cs プロジェクト: gitter-badger/Mvc-4
        internal MvcRazorHost(ICodeTreeCache codeTreeCache, RazorPathNormalizer pathNormalizer)
            : base(new CSharpRazorCodeLanguage())
        {
            _pathNormalizer = pathNormalizer;
            _baseType       = BaseType;
            _codeTreeCache  = codeTreeCache;

            TagHelperDescriptorResolver = new TagHelperDescriptorResolver();
            DefaultBaseClass            = BaseType + "<" + DefaultModel + ">";
            DefaultNamespace            = "Asp";
            // Enable instrumentation by default to allow precompiled views to work with BrowserLink.
            EnableInstrumentation = true;
            GeneratedClassContext = new GeneratedClassContext(
                executeMethodName: "ExecuteAsync",
                writeMethodName: "Write",
                writeLiteralMethodName: "WriteLiteral",
                writeToMethodName: "WriteTo",
                writeLiteralToMethodName: "WriteLiteralTo",
                templateTypeName: "Microsoft.AspNet.Mvc.Razor.HelperResult",
                defineSectionMethodName: "DefineSection",
                generatedTagHelperContext: new GeneratedTagHelperContext
            {
                ExecutionContextTypeName      = typeof(TagHelperExecutionContext).FullName,
                ExecutionContextAddMethodName = nameof(TagHelperExecutionContext.Add),
                ExecutionContextAddTagHelperAttributeMethodName =
                    nameof(TagHelperExecutionContext.AddTagHelperAttribute),
                ExecutionContextAddHtmlAttributeMethodName = nameof(TagHelperExecutionContext.AddHtmlAttribute),
                ExecutionContextOutputPropertyName         = nameof(TagHelperExecutionContext.Output),

                RunnerTypeName           = typeof(TagHelperRunner).FullName,
                RunnerRunAsyncMethodName = nameof(TagHelperRunner.RunAsync),

                ScopeManagerTypeName        = typeof(TagHelperScopeManager).FullName,
                ScopeManagerBeginMethodName = nameof(TagHelperScopeManager.Begin),
                ScopeManagerEndMethodName   = nameof(TagHelperScopeManager.End),

                TagHelperContentTypeName = nameof(TagHelperContent),

                // Can't use nameof because RazorPage is not accessible here.
                CreateTagHelperMethodName            = "CreateTagHelper",
                StartTagHelperWritingScopeMethodName = "StartTagHelperWritingScope",
                EndTagHelperWritingScopeMethodName   = "EndTagHelperWritingScope",

                WriteTagHelperAsyncMethodName   = "WriteTagHelperAsync",
                WriteTagHelperToAsyncMethodName = "WriteTagHelperToAsync",

                // Can't use nameof because IHtmlHelper is (also) not accessible here.
                MarkAsHtmlEncodedMethodName = HtmlHelperPropertyName + ".Raw",
            })
            {
                ResolveUrlMethodName   = "Href",
                BeginContextMethodName = "BeginContext",
                EndContextMethodName   = "EndContext"
            };

            foreach (var ns in _defaultNamespaces)
            {
                NamespaceImports.Add(ns);
            }
        }
コード例 #2
0
ファイル: MvcRazorHost.cs プロジェクト: AndersBillLinden/Mvc
        internal MvcRazorHost(ICodeTreeCache codeTreeCache, RazorPathNormalizer pathNormalizer)
            : base(new CSharpRazorCodeLanguage())
        {
            _pathNormalizer = pathNormalizer;
            _baseType = BaseType;
            _codeTreeCache = codeTreeCache;

            TagHelperDescriptorResolver = new TagHelperDescriptorResolver();
            DefaultBaseClass = BaseType + "<" + DefaultModel + ">";
            DefaultNamespace = "Asp";
            // Enable instrumentation by default to allow precompiled views to work with BrowserLink.
            EnableInstrumentation = true;
            GeneratedClassContext = new GeneratedClassContext(
                executeMethodName: "ExecuteAsync",
                writeMethodName: "Write",
                writeLiteralMethodName: "WriteLiteral",
                writeToMethodName: "WriteTo",
                writeLiteralToMethodName: "WriteLiteralTo",
                templateTypeName: "Microsoft.AspNet.Mvc.Razor.HelperResult",
                defineSectionMethodName: "DefineSection",
                generatedTagHelperContext: new GeneratedTagHelperContext
                {
                    ExecutionContextTypeName = typeof(TagHelperExecutionContext).FullName,
                    ExecutionContextAddMethodName = nameof(TagHelperExecutionContext.Add),
                    ExecutionContextAddTagHelperAttributeMethodName =
                        nameof(TagHelperExecutionContext.AddTagHelperAttribute),
                    ExecutionContextAddHtmlAttributeMethodName = nameof(TagHelperExecutionContext.AddHtmlAttribute),
                    ExecutionContextOutputPropertyName = nameof(TagHelperExecutionContext.Output),

                    RunnerTypeName = typeof(TagHelperRunner).FullName,
                    RunnerRunAsyncMethodName = nameof(TagHelperRunner.RunAsync),

                    ScopeManagerTypeName = typeof(TagHelperScopeManager).FullName,
                    ScopeManagerBeginMethodName = nameof(TagHelperScopeManager.Begin),
                    ScopeManagerEndMethodName = nameof(TagHelperScopeManager.End),

                    TagHelperContentTypeName = nameof(TagHelperContent),

                    // Can't use nameof because RazorPage is not accessible here.
                    CreateTagHelperMethodName = "CreateTagHelper",
                    StartTagHelperWritingScopeMethodName = "StartTagHelperWritingScope",
                    EndTagHelperWritingScopeMethodName = "EndTagHelperWritingScope",

                    WriteTagHelperAsyncMethodName = "WriteTagHelperAsync",
                    WriteTagHelperToAsyncMethodName = "WriteTagHelperToAsync",

                    // Can't use nameof because IHtmlHelper is (also) not accessible here.
                    MarkAsHtmlEncodedMethodName = HtmlHelperPropertyName + ".Raw",
                })
            {
                ResolveUrlMethodName = "Href",
                BeginContextMethodName = "BeginContext",
                EndContextMethodName = "EndContext"
            };

            foreach (var ns in _defaultNamespaces)
            {
                NamespaceImports.Add(ns);
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="ChunkInheritanceUtility"/>.
 /// </summary>
 /// <param name="razorHost">The <see cref="MvcRazorHost"/> used to parse <c>_ViewImports</c> pages.</param>
 /// <param name="codeTreeCache"><see cref="ICodeTreeCache"/> that caches <see cref="CodeTree"/> instances.
 /// </param>
 /// <param name="defaultInheritedChunks">Sequence of <see cref="Chunk"/>s inherited by default.</param>
 public ChunkInheritanceUtility([NotNull] MvcRazorHost razorHost,
                                [NotNull] ICodeTreeCache codeTreeCache,
                                [NotNull] IReadOnlyList <Chunk> defaultInheritedChunks)
 {
     _razorHost = razorHost;
     _defaultInheritedChunks = defaultInheritedChunks;
     _codeTreeCache          = codeTreeCache;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of <see cref="ChunkInheritanceUtility"/>.
 /// </summary>
 /// <param name="razorHost">The <see cref="MvcRazorHost"/> used to parse <c>_GlobalImport</c> pages.</param>
 /// <param name="codeTreeCache"><see cref="ICodeTreeCache"/> that caches <see cref="CodeTree"/> instances.
 /// </param>
 /// <param name="defaultInheritedChunks">Sequence of <see cref="Chunk"/>s inherited by default.</param>
 public ChunkInheritanceUtility([NotNull] MvcRazorHost razorHost,
                                [NotNull] ICodeTreeCache codeTreeCache,
                                [NotNull] IReadOnlyList<Chunk> defaultInheritedChunks)
 {
     _razorHost = razorHost;
     _defaultInheritedChunks = defaultInheritedChunks;
     _codeTreeCache = codeTreeCache;
 }
コード例 #5
0
ファイル: MvcRazorHost.cs プロジェクト: gitter-badger/Mvc-4
 /// <summary>
 /// Initializes a new instance of <see cref="MvcRazorHost"/> using the specified <paramref name="codeTreeCache"/>.
 /// </summary>
 /// <param name="codeTreeCache">An <see cref="ICodeTreeCache"/> rooted at the application base path.</param>
 public MvcRazorHost(ICodeTreeCache codeTreeCache)
     : this(codeTreeCache, new RazorPathNormalizer())
 {
 }
コード例 #6
0
 public TestMvcRazorHost(ICodeTreeCache codeTreeCache)
     : base(codeTreeCache)
 {
 }
コード例 #7
0
ファイル: MvcRazorHost.cs プロジェクト: RehanSaeed/Mvc
 /// <summary>
 /// Initializes a new instance of <see cref="MvcRazorHost"/> using the specified <paramref name="codeTreeCache"/>.
 /// </summary>
 /// <param name="codeTreeCache">An <see cref="ICodeTreeCache"/> rooted at the application base path.</param>
 public MvcRazorHost(ICodeTreeCache codeTreeCache)
     : this(codeTreeCache, new RazorPathNormalizer())
 {
 }
コード例 #8
0
 public TestMvcRazorHost(ICodeTreeCache codeTreeCache)
     : base(codeTreeCache)
 { }