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


C# SyntaxWriter类代码示例

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


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

示例1: WriteSyntax

        /// <inheritdoc />
        public override void WriteSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            writer.WriteStartBlock(this.Language, this.StyleId);

            // Check the list of assemblies for which to generate XAML syntax
            string assemblyName = (string)reflection.Evaluate(apiContainingAssemblyExpression);
            string namespaceName = (string)reflection.Evaluate(apiContainingNamespaceNameExpression);

            if(!xamlAssemblies.ContainsKey(assemblyName))
            {
                WriteXamlBoilerplate(XamlBoilerplateID.nonXamlAssemblyBoilerplate, writer);
            }
            else
            {
                string group = (string)reflection.Evaluate(apiGroupExpression);
                switch(group)
                {
                    case "namespace":
                        WriteNamespaceSyntax(reflection, writer);
                        break;
                    case "type":
                        WriteTypeSyntax(reflection, writer);
                        break;
                    case "member":
                        WriteMemberSyntax(reflection, writer);
                        break;
                }
                WriteXamlXmlnsUri(assemblyName, namespaceName, writer);
            }

            writer.WriteEndBlock();
        }
开发者ID:natarajanmca11,项目名称:SHFB,代码行数:33,代码来源:XamlUsageSyntax.cs

示例2: WriteClassSyntax

        /// <inheritdoc />
        public override void WriteClassSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            string name = reflection.Evaluate(apiNameExpression).ToString();
            bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression);
            bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);
            bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);

            if(isSerializable)
                WriteAttribute("T:System.SerializableAttribute", true, writer);

            WriteAttributes(reflection, writer);

            WriteGenericTemplates(reflection, writer);

            WriteVisibility(reflection, writer);
            writer.WriteString(" ");
            writer.WriteKeyword("ref class");
            writer.WriteString(" ");

            writer.WriteIdentifier(name);

            if(isAbstract)
            {
                writer.WriteString(" ");
                writer.WriteKeyword("abstract");
            }
            if(isSealed)
            {
                writer.WriteString(" ");
                writer.WriteKeyword("sealed");
            }

            WriteBaseClassAndImplementedInterfaces(reflection, writer);

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

示例3: WriteClassSyntax

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

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression);
            bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);

            WriteAccessModifier(reflection, writer);

            if(isSealed)
            {
                writer.WriteKeyword("final");
                writer.WriteString(" ");
            }
            else if(isAbstract)
            {
                writer.WriteKeyword("abstract");
                writer.WriteString(" ");
            }
            writer.WriteKeyword("class");
            writer.WriteString(" ");
            writer.WriteString(name);
            WriteBaseClass(reflection, writer);
            WriteInterfaceList(reflection, writer);
        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:28,代码来源:JScriptDeclarationSyntax.cs

示例4: WriteNamespaceSyntax

        // namespace: done

        /// <inheritdoc />
        public override void WriteNamespaceSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            string name = reflection.Evaluate(apiNameExpression).ToString();

            writer.WriteKeyword("namespace");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:11,代码来源:FSharpDeclarationSyntax.cs

示例5: WriteClassSyntax

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

            string name = reflection.Evaluate(apiNameExpression).ToString();
            bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression);
            bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);
            bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);

            if(isSerializable)
                WriteAttribute("T:System.SerializableAttribute", writer);
            WriteAttributes(reflection, writer);
            WriteVisibility(reflection, writer);
            writer.WriteString(" ");
            if(isSealed)
            {
                writer.WriteKeyword("final");
                writer.WriteString(" ");
            }
            else if(isAbstract)
            {
                writer.WriteKeyword("abstract");
                writer.WriteString(" ");
            }
            writer.WriteKeyword("class");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);

            XPathNavigator baseClass = reflection.SelectSingleNode(apiBaseClassExpression);
            if((baseClass != null) && !((bool)baseClass.Evaluate(typeIsObjectExpression)))
            {
                writer.WriteString(" ");
                writer.WriteKeyword("extends");
                writer.WriteString(" ");
                WriteTypeReference(baseClass, writer);
            }

            WriteImplementedInterfaces(reflection, writer);

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

示例6: WriteConstructorSyntax

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

            string name = (string)reflection.Evaluate(apiContainingTypeNameExpression);

            WriteAttributes(reflection, writer);

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

        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:19,代码来源:FSharpDeclarationSyntax.cs

示例7: WriteVisibility

        // Visibility

        private static void WriteVisibility(XPathNavigator reflection, SyntaxWriter writer)
        {
            string visibility = reflection.Evaluate(apiVisibilityExpression).ToString();
            WriteVisibility(visibility, writer);
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:7,代码来源:FSharpDeclarationSyntax.cs

示例8: WriteDotNetObject

        private void WriteDotNetObject(XPathNavigator reflection, SyntaxWriter writer, string kind)
        {
            string name = reflection.Evaluate(apiNameExpression).ToString();
            bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);
            XPathNodeIterator implements = reflection.Select(apiImplementedInterfacesExpression);
            XPathNavigator baseClass = reflection.SelectSingleNode(apiBaseClassExpression);
            bool hasBaseClass = (baseClass != null) && !((bool)baseClass.Evaluate(typeIsObjectExpression));

            // CLR considers interfaces abstract.
            bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression) && kind != "interface";
            bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);

            if(isAbstract)
                WriteAttribute("T:Microsoft.FSharp.Core.AbstractClassAttribute", true, writer);
            if(isSealed)
                WriteAttribute("T:Microsoft.FSharp.Core.SealedAttribute", true, writer);

            if(isSerializable)
                WriteAttribute("T:System.SerializableAttribute", true, writer);
            WriteAttributes(reflection, writer);

            writer.WriteKeyword("type");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
            WriteGenericTemplates(reflection, writer);
            writer.WriteString(" =  ");

            if(hasBaseClass || implements.Count != 0)
            {
                writer.WriteLine();
                writer.WriteString("    ");
            }
            writer.WriteKeyword(kind);

            if(hasBaseClass || implements.Count != 0)
            {
                writer.WriteLine();
            }

            if(hasBaseClass)
            {
                writer.WriteString("        ");
                writer.WriteKeyword("inherit");
                writer.WriteString(" ");
                WriteTypeReference(baseClass, writer);
                writer.WriteLine();
            }


            while(implements.MoveNext())
            {
                XPathNavigator implement = implements.Current;
                writer.WriteString("        ");
                writer.WriteKeyword("interface");
                writer.WriteString(" ");
                WriteTypeReference(implement, writer);
                writer.WriteLine();
            }

            if(hasBaseClass || implements.Count != 0)
            {
                writer.WriteString("    ");
            }
            else
            {
                writer.WriteString(" ");
            }

            writer.WriteKeyword("end");

        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:71,代码来源:FSharpDeclarationSyntax.cs

示例9: WriteFieldSyntax

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

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
            bool isInitOnly = (bool)reflection.Evaluate(apiIsInitOnlyFieldExpression);
            bool isSerialized = (bool)reflection.Evaluate(apiIsSerializedFieldExpression);

            if(!isSerialized)
                WriteAttribute("T:System.NonSerializedAttribute", true, writer);

            WriteAttributes(reflection, writer);

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

            writer.WriteKeyword("val");
            writer.WriteString(" ");

            if(!isInitOnly)
            {
                writer.WriteKeyword("mutable");
                writer.WriteString(" ");
            }

            WriteVisibility(reflection, writer);

            writer.WriteIdentifier(name);

            writer.WriteString(": ");
            WriteReturnValue(reflection, writer);

        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:40,代码来源:FSharpDeclarationSyntax.cs

示例10: WriteStructureSyntax

 /// <inheritdoc />
 public override void WriteStructureSyntax(XPathNavigator reflection, SyntaxWriter writer)
 {
     WriteDotNetObject(reflection, writer, "struct");
 }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:5,代码来源:FSharpDeclarationSyntax.cs

示例11: WriteDelegateSyntax

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

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

            if(isSerializable)
                WriteAttribute("T:System.SerializableAttribute", true, writer);

            WriteAttributes(reflection, writer);

            writer.WriteKeyword("type");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
            writer.WriteString(" = ");
            writer.WriteLine();
            writer.WriteString("    ");
            writer.WriteKeyword("delegate");
            writer.WriteString(" ");
            writer.WriteKeyword("of");
            writer.WriteString(" ");

            WriteParameters(reflection, writer);

            writer.WriteKeyword("->");
            writer.WriteString(" ");
            WriteReturnValue(reflection, writer);

        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:33,代码来源:FSharpDeclarationSyntax.cs

示例12: 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

示例13: WriteClassSyntax

        /// <inheritdoc />
        public override void WriteClassSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {

            WriteDotNetObject(reflection, writer, "class");
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:6,代码来源:FSharpDeclarationSyntax.cs

示例14: WriteNormalTypeReference

        /// <inheritdoc />
        protected override void WriteNormalTypeReference(string api, SyntaxWriter writer)
        {
            switch(api)
            {
                case "T:System.Void":
                    writer.WriteReferenceLink(api, "unit");
                    break;

                case "T:System.String":
                    writer.WriteReferenceLink(api, "string");
                    break;

                case "T:System.Boolean":
                    writer.WriteReferenceLink(api, "bool");
                    break;

                case "T:System.Byte":
                    writer.WriteReferenceLink(api, "byte");
                    break;

                case "T:System.SByte":
                    writer.WriteReferenceLink(api, "sbyte");
                    break;

                case "T:System.Char":
                    writer.WriteReferenceLink(api, "char");
                    break;

                case "T:System.Int16":
                    writer.WriteReferenceLink(api, "int16");
                    break;

                case "T:System.Int32":
                    writer.WriteReferenceLink(api, "int");
                    break;

                case "T:System.Int64":
                    writer.WriteReferenceLink(api, "int64");
                    break;

                case "T:System.UInt16":
                    writer.WriteReferenceLink(api, "uint16");
                    break;

                case "T:System.UInt32":
                    writer.WriteReferenceLink(api, "uint32");
                    break;

                case "T:System.UInt64":
                    writer.WriteReferenceLink(api, "uint64");
                    break;

                case "T:System.Single":
                    writer.WriteReferenceLink(api, "float32");
                    break;

                case "T:System.Double":
                    writer.WriteReferenceLink(api, "float");
                    break;

                case "T:System.Decimal":
                    writer.WriteReferenceLink(api, "decimal");
                    break;

                default:
                    writer.WriteReferenceLink(api);
                    break;
            }
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:70,代码来源:FSharpDeclarationSyntax.cs

示例15: WriteEnumerationSyntax

        /// <inheritdoc />
        public override void WriteEnumerationSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {

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

            if(isSerializable)
                WriteAttribute("T:System.SerializableAttribute", true, writer);
            WriteAttributes(reflection, writer);
            writer.WriteKeyword("type");
            writer.WriteString(" ");
            WriteVisibility(reflection, writer);
            writer.WriteIdentifier(name);
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:15,代码来源:FSharpDeclarationSyntax.cs


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