当前位置: 首页>>代码示例>>C#>>正文


C# CodeGeneratorContext.GenerateLinePragma方法代码示例

本文整理汇总了C#中System.Web.Razor.Generator.CodeGeneratorContext.GenerateLinePragma方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGeneratorContext.GenerateLinePragma方法的具体用法?C# CodeGeneratorContext.GenerateLinePragma怎么用?C# CodeGeneratorContext.GenerateLinePragma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Razor.Generator.CodeGeneratorContext的用法示例。


在下文中一共展示了CodeGeneratorContext.GenerateLinePragma方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            // Try to find the namespace in the existing imports
            string ns = Namespace;
            if (!String.IsNullOrEmpty(ns) && Char.IsWhiteSpace(ns[0]))
            {
                ns = ns.Substring(1);
            }

            CodeNamespaceImport import = context.Namespace
                .Imports
                .OfType<CodeNamespaceImport>()
                .Where(i => String.Equals(i.Namespace, ns.Trim(), StringComparison.Ordinal))
                .FirstOrDefault();

            if (import == null)
            {
                // It doesn't exist, create it
                import = new CodeNamespaceImport(ns);
                context.Namespace.Imports.Add(import);
            }

            // Attach our info to the existing/new import.
            import.LinePragma = context.GenerateLinePragma(target);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:25,代码来源:AddImportCodeGenerator.cs

示例2: GenerateStartBlockCode

        public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
        {
            _writer = context.CreateCodeWriter();

            string prefix = context.BuildCodeString(
                cw => cw.WriteHelperHeaderPrefix(context.Host.GeneratedClassContext.TemplateTypeName, context.Host.StaticHelpers));

            _writer.WriteLinePragma(
                context.GenerateLinePragma(Signature.Location, prefix.Length, Signature.Value.Length));
            _writer.WriteSnippet(prefix);
            _writer.WriteSnippet(Signature);
            if (HeaderComplete)
            {
                _writer.WriteHelperHeaderSuffix(context.Host.GeneratedClassContext.TemplateTypeName);
            }
            _writer.WriteLinePragma(null);
            if (HeaderComplete)
            {
                _writer.WriteReturn();
                _writer.WriteStartConstructor(context.Host.GeneratedClassContext.TemplateTypeName);
                _writer.WriteStartLambdaDelegate(HelperWriterName);
            }

            _statementCollectorToken = context.ChangeStatementCollector(AddStatementToHelper);
            _oldWriter = context.TargetWriterName;
            context.TargetWriterName = HelperWriterName;
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:27,代码来源:HelperCodeGenerator.cs

示例3: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            context.FlushBufferedStatement();

            string generatedCode = context.BuildCodeString(cw =>
            {
                cw.WriteSnippet(target.Content);
            });

            int startGeneratedCode = target.Start.CharacterIndex;
            generatedCode = Pad(generatedCode, target);

            // Is this the span immediately following "@"?
            if (context.Host.DesignTimeMode &&
                !String.IsNullOrEmpty(generatedCode) &&
                Char.IsWhiteSpace(generatedCode[0]) &&
                target.Previous != null &&
                target.Previous.Kind == SpanKind.Transition &&
                String.Equals(target.Previous.Content, SyntaxConstants.TransitionString))
            {
                generatedCode = generatedCode.Substring(1);
                startGeneratedCode--;
            }

            context.AddStatement(
                generatedCode,
                context.GenerateLinePragma(target, startGeneratedCode));
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:28,代码来源:StatementCodeGenerator.cs

示例4: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            // Build the string
            string code = Prefix + target.Content + ";";

            // Calculate the line pragma including information about where the user-specified code starts and ends (for editors)
            CodeLinePragma pragma = context.GenerateLinePragma(target, Prefix.Length, target.Content.Length);

            // Add the statement
            context.AddStatement(code, pragma);
        }
开发者ID:anurse,项目名称:RazorDemos,代码行数:11,代码来源:ContentTypeCodeGenerator.cs

示例5: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            string generatedCode = context.BuildCodeString(cw =>
            {
                cw.WriteSnippet(target.Content);
            });

            context.GeneratedClass.Members.Add(
                new CodeSnippetTypeMember(Pad(generatedCode, target))
                {
                    LinePragma = context.GenerateLinePragma(target, target.Start.CharacterIndex)
                });
        }
开发者ID:haoduotnt,项目名称:aspnetwebstack,代码行数:13,代码来源:TypeMemberCodeGenerator.cs

示例6: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            context.GeneratedClass.BaseTypes.Clear();
            context.GeneratedClass.BaseTypes.Add(new CodeTypeReference(ResolveType(context)));

            #region Work Around
            if (!(context.Host.CodeLanguage is VBRazorCodeLanguage))
                context.GeneratedClass.LinePragma = context.GenerateLinePragma(target, CalculateSpanPadding(target,0));
            //else
                // exclude VBRazorCodeLanguage
                // with VB I found a problem with the #End ExternalSource directive rendered at the GeneratedClass's end while it should not be rendered
                // this only effects the compile error report

            #endregion
        }
开发者ID:jrnail23,项目名称:RazorMachine,代码行数:15,代码来源:SetModelCodeGenerator.cs

示例7: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            context.FlushBufferedStatement();

            string generatedCode = context.BuildCodeString(cw =>
            {
                cw.WriteSnippet(target.Content);
            });

            int startGeneratedCode = target.Start.CharacterIndex;
            int paddingCharCount;
            generatedCode = CodeGeneratorPaddingHelper.PadStatement(context.Host, generatedCode, target, ref startGeneratedCode, out paddingCharCount);

            context.AddStatement(
                generatedCode,
                context.GenerateLinePragma(target, paddingCharCount));
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:17,代码来源:StatementCodeGenerator.cs

示例8: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            string generatedCode = context.BuildCodeString(cw =>
            {
                cw.WriteSnippet(target.Content);
            });

            int paddingCharCount;
            string paddedCode = CodeGeneratorPaddingHelper.Pad(context.Host, generatedCode, target, out paddingCharCount);

            Contract.Assert(paddingCharCount > 0);

            context.GeneratedClass.Members.Add(
                new CodeSnippetTypeMember(paddedCode)
                {
                    LinePragma = context.GenerateLinePragma(target, paddingCharCount)
                });
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:18,代码来源:TypeMemberCodeGenerator.cs

示例9: GenerateEndBlockCode

        public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
        {
            _statementCollectorToken.Dispose();
            if (HeaderComplete)
            {
                _writer.WriteEndLambdaDelegate();
                _writer.WriteEndConstructor();
                _writer.WriteEndStatement();
            }
            if (Footer != null && !String.IsNullOrEmpty(Footer.Value))
            {
                _writer.WriteLinePragma(
                    context.GenerateLinePragma(Footer.Location, 0, Footer.Value.Length));
                _writer.WriteSnippet(Footer);
                _writer.WriteLinePragma();
            }
            _writer.WriteHelperTrailer();

            context.GeneratedClass.Members.Add(new CodeSnippetTypeMember(_writer.Content));
            context.TargetWriterName = _oldWriter;
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:21,代码来源:HelperCodeGenerator.cs

示例10: GenerateCode

        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            context.GeneratedClass.BaseTypes.Clear();
            context.GeneratedClass.BaseTypes.Add(new CodeTypeReference(ResolveType(context, BaseType.Trim())));

            if (context.Host.DesignTimeMode)
            {
                int generatedCodeStart = 0;
                string code = context.BuildCodeString(cw =>
                {
                    generatedCodeStart = cw.WriteVariableDeclaration(target.Content, "__inheritsHelper", null);
                    cw.WriteEndStatement();
                });

                int paddingCharCount;

                CodeSnippetStatement stmt = new CodeSnippetStatement(
                    CodeGeneratorPaddingHelper.Pad(context.Host, code, target, generatedCodeStart, out paddingCharCount))
                {
                    LinePragma = context.GenerateLinePragma(target, generatedCodeStart + paddingCharCount)
                };
                context.AddDesignTimeHelperStatement(stmt);
            }
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:24,代码来源:SetBaseTypeCodeGenerator.cs


注:本文中的System.Web.Razor.Generator.CodeGeneratorContext.GenerateLinePragma方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。