當前位置: 首頁>>代碼示例>>C#>>正文


C# Tools.SyntaxWriter類代碼示例

本文整理匯總了C#中Microsoft.Ddue.Tools.SyntaxWriter的典型用法代碼示例。如果您正苦於以下問題:C# SyntaxWriter類的具體用法?C# SyntaxWriter怎麽用?C# SyntaxWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SyntaxWriter類屬於Microsoft.Ddue.Tools命名空間,在下文中一共展示了SyntaxWriter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WriteDelegateSyntax

        public override void WriteDelegateSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {

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

            if (isSerializable) WriteAttribute("T:System.SerializableAttribute", 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:jongalloway,項目名稱:dotnetopenid,代碼行數:28,代碼來源:FSharpDeclarationSyntax.cs

示例2: WriteClassSyntax

		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:Balamir,項目名稱:DotNetOpenAuth,代碼行數:35,代碼來源:JSharpDeclarationSyntax.cs

示例3: WriteClassSyntax

        // class: done
		public override void WriteClassSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			string name = (string) reflection.Evaluate(apiNameExpression);
			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 (isAbstract) {
				if (isSealed) {
					// static -- VB doesn't really handle this case
					writer.WriteKeyword("NotInheritable");
					writer.WriteString(" ");
				} else {
					writer.WriteKeyword("MustInherit");
					writer.WriteString(" ");
				}
			} else if (isSealed) {
				writer.WriteKeyword("NotInheritable");
				writer.WriteString(" ");
			}
			writer.WriteKeyword("Class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteGenericTemplates(reflection, writer);
			WriteBaseClass(reflection, writer);
			WriteImplementedInterfaces(reflection, writer);
		}
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:32,代碼來源:VisualBasicDeclarationSyntax.cs

示例4: WriteGenericTemplates

        private void WriteGenericTemplates(XPathNavigator type, SyntaxWriter writer, bool writeVariance)
        {
            XPathNodeIterator templates = type.Select(apiTemplatesExpression);

            if (templates.Count == 0) return;
            writer.WriteString("(");
            writer.WriteKeyword("Of");
            writer.WriteString(" ");
            while (templates.MoveNext())
            {
                XPathNavigator template = templates.Current;
                if (templates.CurrentPosition > 1) writer.WriteString(", ");
                if (writeVariance)
                {
                    bool contravariant = (bool)template.Evaluate(templateIsContravariantExpression);
                    bool covariant = (bool)template.Evaluate(templateIsCovariantExpression);

                    if (contravariant)
                    {
                        writer.WriteKeyword("In");
                        writer.WriteString(" ");
                    }
                    if (covariant)
                    {
                        writer.WriteKeyword("Out");
                        writer.WriteString(" ");
                    }
                }

                string name = template.GetAttribute("name", String.Empty);
                writer.WriteString(name);
            }
            writer.WriteString(")");

        }
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:35,代碼來源:VisualBasicUsageSyntax.cs

示例5: WriteSyntax

        public override void WriteSyntax (XPathNavigator reflection, SyntaxWriter writer) {

            string group = (string)reflection.Evaluate(groupExpression);
            string subgroup = (string)reflection.Evaluate(subgroupExpression);

            if (group == "type" && subgroup == "class") {
                string prefix = WebControlPrefix(reflection);
                if (!String.IsNullOrEmpty(prefix)) {
                    WriteClassSyntax(reflection, writer, prefix);
                }
            }

            if (group == "member") {

                string prefix = null;
                XPathNavigator containingType = reflection.SelectSingleNode(containingTypeExpression);
                if (containingType != null) prefix = WebControlPrefix(containingType);

                if (!String.IsNullOrEmpty(prefix)) {
                    if (subgroup == "property") {
                        WritePropertySyntax(reflection, writer, prefix);
                    } else if (subgroup == "event") {
                        WriteEventSyntax(reflection, writer, prefix);
                    }
                }
            }


        }
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:29,代碼來源:AspNetSyntax.cs

示例6: WriteSyntax

        public override void WriteSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            writer.WriteStartBlock(Language);

            // 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.ToLower()))
            {
                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:hnlshzx,項目名稱:DotNetOpenAuth,代碼行數:31,代碼來源:XamlUsageSyntax.cs

示例7: WriteNamespaceSyntax

        public override void WriteNamespaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            string name = (string)reflection.Evaluate(apiNameExpression);

            writer.WriteKeyword("package");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
        }
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:7,代碼來源:JScriptDeclarationSyntax.cs

示例8: WriteClassSyntax

        // class: done
		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", writer);
			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			if (isAbstract) {
				if (isSealed) {
					writer.WriteKeyword("static");
				} else {
					writer.WriteKeyword("abstract");
				}
				writer.WriteString(" ");
			} else {
				if (isSealed) {
					writer.WriteKeyword("sealed");
					writer.WriteString(" ");
				}
			}
			writer.WriteKeyword("class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteGenericTemplates(reflection, writer);
			WriteBaseClassAndImplementedInterfaces(reflection, writer);
			WriteGenericTemplateConstraints(reflection, writer);

		}
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:33,代碼來源:CSharpDeclarationSyntax.cs

示例9: WriteEnumerationSyntax

        public override void WriteEnumerationSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            string name = (string)reflection.Evaluate(apiNameExpression);

            WriteAttributeList(reflection, writer);
            WriteAccessModifier(reflection, writer);
            writer.WriteKeyword("enum");
            writer.WriteString(" ");
            writer.WriteString(name);
            // no JScript support for underlying types
        }
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:10,代碼來源:JScriptDeclarationSyntax.cs

示例10: WriteInterfaceSyntax

        public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            if (IsUnsupportedGeneric(reflection, writer)) return;

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

            WriteAttributeList(reflection, writer);
            WriteAccessModifier(reflection, writer);
            writer.WriteKeyword("interface");
            writer.WriteString(" ");
            writer.WriteString(name);
            WriteInterfaceList("extends", reflection, writer);
        }
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:12,代碼來源:JScriptDeclarationSyntax.cs

示例11: WriteEnumerationSyntax

        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", writer);
            WriteAttributes(reflection, writer);
            writer.WriteKeyword("type");
            writer.WriteString(" ");
            WriteVisibility(reflection, writer);
            writer.WriteIdentifier(name);
        }
開發者ID:jongalloway,項目名稱:dotnetopenid,代碼行數:13,代碼來源:FSharpDeclarationSyntax.cs

示例12: WriteInterfaceSyntax

        // interface: done
		public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {

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

			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			writer.WriteKeyword("Interface");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
            WriteGenericTemplates(reflection, writer, true); // Need to write variance info for interfaces and delegates
			WriteImplementedInterfaces(reflection, writer);
		}
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:14,代碼來源:VisualBasicDeclarationSyntax.cs

示例13: WriteConstructorSyntax

        public override void WriteConstructorSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
            if (isStatic) {
                writer.WriteMessage("UnsupportedStaticConstructor_" + Language);
            } else {
                if (IsUnsupportedUnsafe(reflection, writer)) return;
                XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);

                WriteAttributeList(reflection, writer);
                WriteAccessModifier(reflection, writer);
                writer.WriteKeyword("function");
                writer.WriteString(" ");
                WriteTypeReference(declaringType, writer);
                WriteParameterList(reflection, writer);
            }
        }
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:16,代碼來源:JScriptDeclarationSyntax.cs

示例14: WriteInterfaceSyntax

		public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {

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

			WriteAttributes(reflection, writer);

			WriteGenericTemplates(reflection, writer);

			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			writer.WriteKeyword("interface class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteImplementedInterfaces(reflection, writer);

		}
開發者ID:jongalloway,項目名稱:dotnetopenid,代碼行數:16,代碼來源:CPlusPlusDeclarationSyntax.cs

示例15: WriteStructureSyntax

        // structure: done
		public override void WriteStructureSyntax (XPathNavigator reflection, SyntaxWriter writer) {

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

			if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			writer.WriteKeyword("struct");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteGenericTemplates(reflection, writer);
			WriteImplementedInterfaces(reflection, writer);
			WriteGenericTemplateConstraints(reflection, writer);

		}
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:18,代碼來源:CSharpDeclarationSyntax.cs


注:本文中的Microsoft.Ddue.Tools.SyntaxWriter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。