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


C# SyntaxWriter.WriteLine方法代码示例

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


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

示例1: WriteCastSyntax

        /// <inheritdoc />
        public override void WriteCastSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            XPathNavigator parameter = reflection.SelectSingleNode(apiParametersExpression);
            if(parameter == null)
                return;
            XPathNavigator inputType = parameter.SelectSingleNode(typeExpression);
            XPathNavigator outputType = reflection.SelectSingleNode(apiReturnTypeExpression);
            if((inputType == null) || (outputType == null))
                return;

            ParameterDeclaration("input", inputType, writer);
            ParameterDeclaration("output", outputType, writer);
            writer.WriteLine();
            writer.WriteParameter("output");
            writer.WriteString(" = ");
            writer.WriteKeyword("CType");
            writer.WriteString("(");
            writer.WriteParameter("input");
            writer.WriteString(", ");
            WriteTypeReference(outputType, writer);
            writer.WriteString(")");
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:23,代码来源:VisualBasicUsageSyntax.cs

示例2: WriteAttribute

        // Attributes

        // !EFW - Added newLine parameter
        private static void WriteAttribute(string reference, bool newLine, SyntaxWriter writer)
        {
            writer.WriteString("[<");
            writer.WriteReferenceLink(reference);
            writer.WriteString(">]");

            if(newLine)
                writer.WriteLine();
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:12,代码来源:FSharpDeclarationSyntax.cs

示例3: WriteInteropAttributes

        // EFW - Added support for interop attributes stored in metadata
        private void WriteInteropAttributes(XPathNavigator reflection, SyntaxWriter writer, string indent = null)
        {
            if((bool)reflection.Evaluate(apiComImportTypeExpression))
                WriteAttribute("T:System.Runtime.InteropServices.ComImportAttribute", true, writer);

            string layout = (string)reflection.Evaluate(apiStructLayoutTypeExpression);

            if(!String.IsNullOrEmpty(layout))
            {
                double size = (double)reflection.Evaluate(apiStructLayoutSizeTypeExpression),
                    pack = (double)reflection.Evaluate(apiStructLayoutPackTypeExpression);
                string format = (string)reflection.Evaluate(apiStructLayoutFormatTypeExpression);

                writer.WriteString("[<");
                WriteNormalTypeReference("T:System.Runtime.InteropServices.StructLayoutAttribute", writer);
                writer.WriteString("(");

                switch(layout)
                {
                    case "explicit":
                        writer.WriteString("LayoutKind.Explicit");
                        break;

                    case "sequential":
                        writer.WriteString("LayoutKind.Sequential");
                        break;

                    default:
                        writer.WriteString("LayoutKind.Auto");
                        break;
                }

                if(!Double.IsNaN(size) && size != 0)
                {
                    WriteWithLineBreakIfNeeded(writer, ", ", indent + "\t");
                    writer.WriteString("Size = ");
                    writer.WriteString(((int)size).ToString(CultureInfo.InvariantCulture));
                }

                if(!Double.IsNaN(pack) && pack != 0)
                {
                    WriteWithLineBreakIfNeeded(writer, ", ", indent + "\t");
                    writer.WriteString("Pack = ");
                    writer.WriteString(((int)pack).ToString(CultureInfo.InvariantCulture));
                }

                switch(format)
                {
                    case "ansi":
                        WriteWithLineBreakIfNeeded(writer, ", ", indent + "\t");
                        writer.WriteString("CharSet = CharSet.Ansi");
                        break;

                    case "auto":
                        WriteWithLineBreakIfNeeded(writer, ", ", indent + "\t");
                        writer.WriteString("CharSet = CharSet.Auto");
                        break;

                    case "unicode":
                        WriteWithLineBreakIfNeeded(writer, ", ", indent + "\t");
                        writer.WriteString("CharSet = CharSet.Unicode");
                        break;
                }

                writer.WriteString(")");
                writer.WriteString(">]");
                writer.WriteLine();
            }

            double fieldOffset = (double)reflection.Evaluate(apiFieldOffsetFieldExpression);

            if(!Double.IsNaN(fieldOffset))
            {
                writer.WriteString("[<");
                WriteNormalTypeReference("T:System.Runtime.InteropServices.FieldOffsetAttribute", writer);
                writer.WriteString("(");
                writer.WriteString(((int)fieldOffset).ToString(CultureInfo.InvariantCulture));
                writer.WriteString(")");
                writer.WriteString(">]");
                writer.WriteLine();
            }

            bool preserveSig = (bool)reflection.Evaluate(apiPreserveSigProcedureExpression);
            string module = (string)reflection.Evaluate(apiModuleProcedureExpression);

            if(!String.IsNullOrEmpty(module))
            {
                string entryPoint = (string)reflection.Evaluate(apiEntryPointProcedureExpression),
                    callingConv = (string)reflection.Evaluate(apiCallingConvProcedureExpression),
                    charset = (string)reflection.Evaluate(apiCharSetProcedureExpression),
                    bestFitMapping = (string)reflection.Evaluate(apiBestFitMappingProcedureExpression);

                bool exactSpelling = (bool)reflection.Evaluate(apiExactSpellingProcedureExpression),
                    throwOnUnmappableChar = (bool)reflection.Evaluate(apiUnmappableCharProcedureExpression),
                    setLastError = (bool)reflection.Evaluate(apiSetLastErrorProcedureExpression);

                writer.WriteString("[<");
                WriteNormalTypeReference("T:System.Runtime.InteropServices.DllImportAttribute", writer);
                writer.WriteString("(\"");
//.........这里部分代码省略.........
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:101,代码来源:FSharpDeclarationSyntax.cs

示例4: WriteNormalMethodSyntax

        /// <inheritdoc />
        public override void WriteNormalMethodSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            // !EFW - Added unsafe check
            if(IsUnsupportedUnsafe(reflection, writer))
                return;

            if(IsUnsupportedVarargs(reflection, writer))
                return;

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
            bool isVirtual = (bool)reflection.Evaluate(apiIsVirtualExpression) && !(bool)reflection.Evaluate(apiIsAbstractProcedureExpression);
            int iterations = isVirtual ? 2 : 1;

            for(int i = 0; i < iterations; i++)
            {

                WriteAttributes(reflection, writer);

                WriteVisibility(reflection, writer);

                if(isStatic)
                {
                    writer.WriteKeyword("static");
                    writer.WriteString(" ");
                }

                if(isVirtual)
                    if(i == 0)
                    {
                        writer.WriteKeyword("abstract");
                        writer.WriteString(" ");
                    }
                    else
                    {
                        writer.WriteKeyword("override");
                        writer.WriteString(" ");
                    }
                else
                {
                    WriteMemberKeyword(reflection, writer);
                }

                writer.WriteIdentifier(name);
                writer.WriteString(" : ");
                WriteParameters(reflection, writer);
                writer.WriteKeyword("->");
                writer.WriteString(" ");
                WriteReturnValue(reflection, writer);
                writer.WriteString(" ");
                WriteGenericTemplateConstraints(reflection, writer);

                if(i == 0)
                    writer.WriteLine();
            }
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:57,代码来源:FSharpDeclarationSyntax.cs

示例5: WriteEventSyntax

        /// <inheritdoc />
        public override void WriteEventSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            // !EFW - Added unsafe check
            if(IsUnsupportedUnsafe(reflection, writer))
                return;

            string name = (string)reflection.Evaluate(apiNameExpression);
            XPathNavigator handler = reflection.SelectSingleNode(apiHandlerOfEventExpression);
            XPathNavigator args = reflection.SelectSingleNode(apiEventArgsExpression);
            bool isVirtual = (bool)reflection.Evaluate(apiIsVirtualExpression) && !(bool)reflection.Evaluate(apiIsAbstractProcedureExpression);
            int iterations = isVirtual ? 2 : 1;

            for(int i = 0; i < iterations; i++)
            {
                WriteAttributes(reflection, writer);
                WriteVisibility(reflection, writer);
                if(isVirtual)
                    if(i == 0)
                    {
                        writer.WriteKeyword("abstract");
                        writer.WriteString(" ");
                    }
                    else
                    {
                        writer.WriteKeyword("override");
                        writer.WriteString(" ");
                    }
                else
                {
                    WriteMemberKeyword(reflection, writer);
                }
                writer.WriteIdentifier(name);
                writer.WriteString(" : ");
                writer.WriteReferenceLink("T:Microsoft.FSharp.Control.IEvent`2");

                writer.WriteString("<");
                WriteTypeReference(handler, writer);
                writer.WriteString(",");
                writer.WriteLine();
                writer.WriteString("    ");
                if(args == null)
                {
                    writer.WriteReferenceLink("T:System.EventArgs");
                }
                else
                {
                    WriteTypeReference(args, writer);
                }
                writer.WriteString(">");
                if(i == 0)
                    writer.WriteLine();
            }
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:54,代码来源:FSharpDeclarationSyntax.cs

示例6: WritePropertySyntax

        /// <inheritdoc />
        public override void WritePropertySyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            if(IsUnsupportedUnsafe(reflection, writer))
                return;

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool hasGetter = (bool)reflection.Evaluate(apiIsReadPropertyExpression);
            bool hasSetter = (bool)reflection.Evaluate(apiIsWritePropertyExpression);
            bool isDefault = (bool)reflection.Evaluate(apiIsDefaultMemberExpression);
            bool isExplicit = (bool)reflection.Evaluate(apiIsExplicitImplementationExpression);
            XPathNavigator type = reflection.SelectSingleNode(apiReturnTypeExpression);

            WriteAttributes(reflection, writer);
            WriteProcedureModifiers(reflection, writer);

            if(hasGetter && !hasSetter)
            {
                writer.WriteKeyword("ReadOnly");
                writer.WriteString(" ");
            }
            else if(hasSetter && !hasGetter)
            {
                writer.WriteKeyword("WriteOnly");
                writer.WriteString(" ");
            }

            if(isDefault)
            {
                writer.WriteKeyword("Default");
                writer.WriteString(" ");
            }

            writer.WriteKeyword("Property");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
            WriteParameters(reflection, writer);
            writer.WriteString(" ");
            writer.WriteKeyword("As");
            writer.WriteString(" ");
            WriteTypeReference(type, writer);

            if(isExplicit)
            {
                if(writer.Position > MaxPosition)
                {
                    writer.WriteLine();
                    writer.WriteString("\t");
                }
                else
                {
                    writer.WriteString(" ");
                }

                writer.WriteKeyword("Implements");
                writer.WriteString(" ");
                XPathNodeIterator implementations = reflection.Select(apiImplementedMembersExpression);

                while(implementations.MoveNext())
                {
                    XPathNavigator implementation = implementations.Current;
                    XPathNavigator contract = implementation.SelectSingleNode(memberDeclaringTypeExpression);
                    //string id = implementation.GetAttribute("api", String.Empty);
                    if(implementations.CurrentPosition > 1)
                        writer.WriteString(", ");
                    WriteTypeReference(contract, writer);
                    writer.WriteString(".");
                    WriteMemberReference(implementation, writer);
                    //writer.WriteReferenceLink(id);	
                }
            }

            if(hasGetter)
            {
                writer.WriteLine();

                // !EFW - Added support for getter/setter attributes
                XPathNavigator getter = reflection.SelectSingleNode(apiGetterExpression);

                if(getter != null && getter.HasChildren)
                {
                    writer.WriteString("\t");
                    this.WriteAttributes(getter, writer, "\t");
                }

                writer.WriteString("\t");

                string getVisibility = (string)reflection.Evaluate(apiGetVisibilityExpression);

                if(!String.IsNullOrEmpty(getVisibility))
                {
                    WriteVisibility(getVisibility, writer);
                    writer.WriteString(" ");
                }

                writer.WriteKeyword("Get");
            }

            if(hasSetter)
            {
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:101,代码来源:VisualBasicDeclarationSyntax.cs

示例7: WriteAttribute

        private void WriteAttribute(string reference, bool newLine, SyntaxWriter writer)
        {
            writer.WriteString("<");
            writer.WriteReferenceLink(reference);
            writer.WriteString(">");

            if(newLine)
            {
                if(includeLineContinuation)
                    writer.WriteString(" _");

                writer.WriteLine();
            }
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:14,代码来源:VisualBasicDeclarationSyntax.cs

示例8: WriteEventSyntax

        /// <inheritdoc />
        public override void WriteEventSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            if(IsUnsupportedUnsafe(reflection, writer))
                return;

            string name = (string)reflection.Evaluate(apiNameExpression);
            XPathNavigator handler = reflection.SelectSingleNode(apiHandlerOfEventExpression);

            writer.WriteString("/** @event */");
            writer.WriteLine();
            // add_ method declaration
            WriteAttributes(reflection, writer);
            WriteProcedureModifiers(reflection, writer);
            WriteReturnValue(reflection, writer);
            writer.WriteString(" ");
            writer.WriteIdentifier("add_" + name);
            writer.WriteString(" (");
            WriteTypeReference(handler, writer);
            writer.WriteString(" ");
            writer.WriteParameter("value");
            writer.WriteString(")");
            writer.WriteLine();

            writer.WriteString("/** @event */");
            writer.WriteLine();
            // remove_ method declaration
            WriteAttributes(reflection, writer);
            WriteProcedureModifiers(reflection, writer);
            WriteReturnValue(reflection, writer);
            writer.WriteString(" ");
            writer.WriteIdentifier("remove_" + name);
            writer.WriteString(" (");
            WriteTypeReference(handler, writer);
            writer.WriteString(" ");
            writer.WriteParameter("value");
            writer.WriteString(")");
            writer.WriteLine();

        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:40,代码来源:JSharpDeclarationSyntax.cs

示例9: WriteAttribute

        private static void WriteAttribute(string reference, SyntaxWriter writer, bool newline)
        {
            writer.WriteString("/** @attribute ");
            writer.WriteReferenceLink(reference);
            writer.WriteString(" */ ");

            if(newline)
                writer.WriteLine();
        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:9,代码来源:JSharpDeclarationSyntax.cs

示例10: WriteDelegateSyntax

        /// <inheritdoc />
        public override void WriteDelegateSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            if(IsUnsupportedUnsafe(reflection, writer))
                return;
            if(IsUnsupportedGeneric(reflection, writer))
                return;

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);

            writer.WriteString("/** @delegate */");
            writer.WriteLine();

            if(isSerializable)
                WriteAttribute("T:System.SerializableAttribute", writer);
            WriteAttributes(reflection, writer);
            WriteVisibility(reflection, writer);
            writer.WriteString(" ");
            writer.WriteKeyword("delegate");
            writer.WriteString(" ");
            WriteReturnValue(reflection, writer);
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
            WriteMethodParameters(reflection, writer);

        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:27,代码来源:JSharpDeclarationSyntax.cs

示例11: WritePropertySyntax

        /// <inheritdoc />
        public override void WritePropertySyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            if(IsUnsupportedUnsafe(reflection, writer))
                return;

            if(IsUnsupportedExplicit(reflection, writer))
                return;

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isGettable = (bool)reflection.Evaluate(apiIsReadPropertyExpression);
            bool isSettable = (bool)reflection.Evaluate(apiIsWritePropertyExpression);

            if(isGettable)
            {
                writer.WriteString("/** @property */");
                writer.WriteLine();

                // !EFW - Added support for getter/setter attributes
                XPathNavigator getter = reflection.SelectSingleNode(apiGetterExpression);

                if(getter != null && getter.HasChildren)
                    this.WriteAttributes(getter, writer);

                // write getter method
                WriteAttributes(reflection, writer);
                WriteProcedureModifiers(reflection, writer);
                WriteReturnValue(reflection, writer);
                writer.WriteString(" ");
                writer.WriteIdentifier("get_" + name);
                WriteMethodParameters(reflection, writer);
                writer.WriteLine();
            }

            if(isSettable)
            {
                writer.WriteString("/** @property */");
                writer.WriteLine();

                // !EFW - Added support for getter/setter attributes
                XPathNavigator setter = reflection.SelectSingleNode(apiSetterExpression);

                if(setter != null && setter.HasChildren)
                    this.WriteAttributes(setter, writer);

                // write setter method
                WriteAttributes(reflection, writer);
                WriteProcedureModifiers(reflection, writer);
                writer.WriteKeyword("void");
                writer.WriteString(" ");
                writer.WriteIdentifier("set_" + name);

                // parameters
                writer.WriteString("(");
                WriteReturnValue(reflection, writer);
                writer.WriteString(" ");
                writer.WriteParameter("value");
                writer.WriteString(")");

                // end parameters
                writer.WriteLine();
            }
        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:63,代码来源:JSharpDeclarationSyntax.cs

示例12: WriteParameters

        private void WriteParameters(XPathNodeIterator parameters, SyntaxWriter writer)
        {
            while(parameters.MoveNext())
            {
                XPathNavigator parameter = parameters.Current;
                string name = (string)parameter.Evaluate(parameterNameExpression);
                writer.WriteParameter(name);

                if(parameters.CurrentPosition < parameters.Count)
                {
                    writer.WriteString(", ");

                    if(writer.Position > MaxPosition)
                    {
                        if(includeLineContinuation)
                            writer.WriteString("_");

                        writer.WriteLine();
                        writer.WriteString("\t");
                    }
                }
            }
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:23,代码来源:VisualBasicUsageSyntax.cs

示例13: WriteEventSyntax

        /// <inheritdoc />
        public override void WriteEventSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            // !EFW - Added unsafe check
            if(IsUnsupportedUnsafe(reflection, writer))
                return;

            bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
            bool isFamily = (bool)reflection.Evaluate(apiIsFamilyMemberExpression);
            XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);
            XPathNavigator handler = reflection.SelectSingleNode(apiHandlerOfEventExpression);

            if(!(isStatic | isFamily))
                ParameterDeclaration("instance", declaringType, writer);
            ParameterDeclaration("handler", handler, writer);

            // adder
            writer.WriteLine();
            writer.WriteKeyword("AddHandler");
            writer.WriteString(" ");
            WriteMemberName(reflection, writer);
            writer.WriteString(", ");
            writer.WriteParameter("handler");
            writer.WriteLine();
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:25,代码来源:VisualBasicUsageSyntax.cs

示例14: WritePropertySyntax

        /// <inheritdoc />
        public override void WritePropertySyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            if(IsUnsupportedUnsafe(reflection, writer))
                return;

            bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
            bool isFamily = (bool)reflection.Evaluate(apiIsFamilyMemberExpression);
            XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);
            XPathNavigator propertyType = reflection.SelectSingleNode(apiReturnTypeExpression);
            bool getter = (bool)reflection.Evaluate(apiIsReadPropertyExpression);
            bool setter = (bool)reflection.Evaluate(apiIsWritePropertyExpression);

            if(!(isStatic || isFamily))
                ParameterDeclaration("instance", declaringType, writer);
            WriteParameterDeclarations(reflection, writer);
            ParameterDeclaration("value", propertyType, writer);

            // get value
            if(getter)
            {
                string getVisibility = (string)reflection.Evaluate(apiGetVisibilityExpression);
                if(string.IsNullOrEmpty(getVisibility) || (getVisibility != "assembly" &&
                    getVisibility != "private" && getVisibility != "family and assembly"))
                {
                    writer.WriteLine();
                    writer.WriteParameter("value");
                    writer.WriteString(" = ");
                    WriteMemberName(reflection, writer);
                    WritePropertyParameters(reflection, writer);
                    writer.WriteLine();
                }
            }

            // set value
            if(setter)
            {
                string setVisibility = (string)reflection.Evaluate(apiSetVisibilityExpression);
                if(string.IsNullOrEmpty(setVisibility) || (setVisibility != "assembly" &&
                    setVisibility != "private" && setVisibility != "family and assembly"))
                {
                    writer.WriteLine();
                    WriteMemberName(reflection, writer);
                    WritePropertyParameters(reflection, writer);
                    writer.WriteString(" = ");
                    writer.WriteParameter("value");
                }
            }

        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:50,代码来源:VisualBasicUsageSyntax.cs

示例15: WriteWithLineBreakIfNeededVB

        /// <summary>
        /// This is used to write a string followed by an optional line break if needed (the writer position is
        /// past the maximum position afterwards).
        /// </summary>
        /// <param name="writer">The syntax writer to use</param>
        /// <param name="text">An optional text string to write before the new line</param>
        /// <param name="indent">An optional indent to write after the line break</param>
        /// <returns>True if a new line was written, false if not</returns>
        private bool WriteWithLineBreakIfNeededVB(SyntaxWriter writer, string text, string indent)
        {
            if(!String.IsNullOrEmpty(text))
                writer.WriteString(text);

            if(writer.Position > MaxPosition)
            {
                if(includeLineContinuation)
                    writer.WriteString(" _");

                writer.WriteLine();

                if(!String.IsNullOrEmpty(indent))
                    writer.WriteString(indent);

                return true;
            }

            return false;
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:28,代码来源:VisualBasicDeclarationSyntax.cs


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