本文整理汇总了C#中CSharpSyntaxGenerator.Node类的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于CSharpSyntaxGenerator命名空间,在下文中一共展示了Node类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DetermineMinimalFactoryFields
private IEnumerable<Field> DetermineMinimalFactoryFields(Node nd)
{
// special case to allow a single optional argument if there would have been no arguments
// and we can determine a best single argument.
Field allowOptionalField = null;
var optionalCount = OptionalFactoryArgumentCount(nd);
if (optionalCount == 0)
{
return null; // no fields...
}
var requiredCount = RequiredFactoryArgumentCount(nd, includeKind: false);
if (requiredCount == 0 && optionalCount > 1)
{
allowOptionalField = DetermineMinimalOptionalField(nd);
}
return nd.Fields.Where(f => IsRequiredFactoryField(nd, f) || allowOptionalField == f);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:20,代码来源:SourceWriter.cs
示例2: DetermineMinimalOptionalField
private Field DetermineMinimalOptionalField(Node nd)
{
// first if there is a single list, then choose the list because it would not have been optional
int listCount = nd.Fields.Count(f => IsAnyNodeList(f.Type));
if (listCount == 1)
{
return nd.Fields.First(f => IsAnyNodeList(f.Type));
}
else
{
// otherwise, if there is a single optional node, use that..
int nodeCount = nd.Fields.Count(f => IsNode(f.Type) && f.Type != "SyntaxToken");
if (nodeCount == 1)
{
return nd.Fields.First(f => IsNode(f.Type) && f.Type != "SyntaxToken");
}
else
{
return null;
}
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:22,代码来源:SourceWriter.cs
示例3: WriteGreenFactoryParameters
private void WriteGreenFactoryParameters(Node nd)
{
if (nd.Kinds.Count > 1)
{
Write("SyntaxKind kind, ");
}
for (int i = 0, n = nd.Fields.Count; i < n; i++)
{
var field = nd.Fields[i];
if (i > 0)
Write(", ");
var type = field.Type;
if (type == "SyntaxNodeOrTokenList")
{
type = "Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList<CSharpSyntaxNode>";
}
else if (IsSeparatedNodeList(field.Type) ||
IsNodeList(field.Type))
{
type = "Microsoft.CodeAnalysis.Syntax.InternalSyntax." + type;
}
Write("{0} {1}", type, CamelCase(field.Name));
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:24,代码来源:SourceWriter.cs
示例4: WriteGreenUpdateMethod
private void WriteGreenUpdateMethod(Node node)
{
WriteLine();
Write(" public {0} Update(", node.Name);
// parameters
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
if (f > 0)
Write(", ");
var type =
field.Type == "SyntaxNodeOrTokenList" ? "Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList<CSharpSyntaxNode>" :
field.Type == "SyntaxTokenList" ? "Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList<SyntaxToken>" :
IsNodeList(field.Type) ? "Microsoft.CodeAnalysis.Syntax.InternalSyntax." + field.Type :
IsSeparatedNodeList(field.Type) ? "Microsoft.CodeAnalysis.Syntax.InternalSyntax." + field.Type :
field.Type;
Write("{0} {1}", type, CamelCase(field.Name));
}
WriteLine(")");
WriteLine(" {");
Write(" if (");
int nCompared = 0;
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
if (IsDerivedOrListOfDerived("SyntaxNode", field.Type) || IsDerivedOrListOfDerived("SyntaxToken", field.Type) || field.Type == "SyntaxNodeOrTokenList")
{
if (nCompared > 0)
Write(" || ");
Write("{0} != this.{1}", CamelCase(field.Name), field.Name);
nCompared++;
}
}
if (nCompared > 0)
{
WriteLine(")");
WriteLine(" {");
Write(" var newNode = SyntaxFactory.{0}(", StripPost(node.Name, "Syntax"));
if (node.Kinds.Count > 1)
{
Write("this.Kind, ");
}
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
if (f > 0)
Write(", ");
Write(CamelCase(field.Name));
}
WriteLine(");");
WriteLine(" var diags = this.GetDiagnostics();");
WriteLine(" if (diags != null && diags.Length > 0)");
WriteLine(" newNode = newNode.WithDiagnosticsGreen(diags);");
WriteLine(" var annotations = this.GetAnnotations();");
WriteLine(" if (annotations != null && annotations.Length > 0)");
WriteLine(" newNode = newNode.WithAnnotationsGreen(annotations);");
WriteLine(" return newNode;");
WriteLine(" }");
}
WriteLine();
WriteLine(" return this;");
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:68,代码来源:SourceWriter.cs
示例5: WriteSetDiagnostics
private void WriteSetDiagnostics(Node node)
{
WriteLine();
WriteLine(" internal override GreenNode SetDiagnostics(DiagnosticInfo[] diagnostics)");
WriteLine(" {");
Write(" return new {0}(", node.Name);
Write("this.Kind, ");
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
if (f > 0)
Write(", ");
Write("this.{0}", CamelCase(field.Name));
}
WriteLine(", diagnostics, GetAnnotations());");
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:18,代码来源:SourceWriter.cs
示例6: WriteRedMinimalFactory
// creates a factory with only the required arguments (everything else is defaulted)
private void WriteRedMinimalFactory(Node nd, bool withStringNames = false)
{
var optionalCount = OptionalFactoryArgumentCount(nd);
if (optionalCount == 0)
return; // already handled w/ general factory method
var minimalFactoryfields = new HashSet<Field>(DetermineMinimalFactoryFields(nd));
if (withStringNames && minimalFactoryfields.Count(f => IsRequiredFactoryField(nd, f) && CanAutoConvertFromString(f)) == 0)
return; // no string-name overload necessary
this.WriteLine();
WriteComment(string.Format("<summary>Creates a new {0} instance.</summary>", nd.Name), " ");
Write(" {0} static {1} {2}(", "public", nd.Name, StripPost(nd.Name, "Syntax"));
bool hasPreviousParameter = false;
if (nd.Kinds.Count > 1)
{
Write("SyntaxKind kind");
hasPreviousParameter = true;
}
for (int i = 0, n = nd.Fields.Count; i < n; i++)
{
var field = nd.Fields[i];
if (minimalFactoryfields.Contains(field))
{
var type = GetRedPropertyType(field);
if (IsRequiredFactoryField(nd, field))
{
if (hasPreviousParameter)
Write(", ");
if (withStringNames && CanAutoConvertFromString(field))
{
type = "string";
}
Write("{0} {1}", type, CamelCase(field.Name));
hasPreviousParameter = true;
}
else
{
if (hasPreviousParameter)
Write(", ");
Write("{0} {1} = default({0})", type, CamelCase(field.Name));
hasPreviousParameter = true;
}
}
}
WriteLine(")");
WriteLine(" {");
Write(" return SyntaxFactory.{0}(", StripPost(nd.Name, "Syntax"));
bool hasPreviousArgument = false;
if (nd.Kinds.Count > 1)
{
Write("kind");
hasPreviousArgument = true;
}
for (int i = 0, n = nd.Fields.Count; i < n; i++)
{
var field = nd.Fields[i];
if (hasPreviousArgument)
Write(", ");
if (minimalFactoryfields.Contains(field))
{
if (IsRequiredFactoryField(nd, field))
{
if (withStringNames && CanAutoConvertFromString(field))
{
Write("{0}({1})", GetStringConverterMethod(field), CamelCase(field.Name));
}
else
{
Write("{0}", CamelCase(field.Name));
}
}
else
{
if (IsOptional(field) || IsAnyList(field.Type))
{
Write("{0}", CamelCase(field.Name));
}
else
{
Write("{0} ?? {1}", CamelCase(field.Name), GetDefaultValue(nd, field));
}
//.........这里部分代码省略.........
开发者ID:XieShuquan,项目名称:roslyn,代码行数:101,代码来源:SourceWriter.cs
示例7: DetermineRedFactoryWithNoAutoCreatableTokenFields
private IEnumerable<Field> DetermineRedFactoryWithNoAutoCreatableTokenFields(Node nd)
{
return nd.Fields.Where(f => !IsAutoCreatableToken(nd, f));
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:4,代码来源:SourceWriter.cs
示例8: GetDefaultValue
private string GetDefaultValue(Node nd, Field field)
{
System.Diagnostics.Debug.Assert(!IsRequiredFactoryField(nd, field));
if (IsOptional(field) || IsAnyList(field.Type))
{
return string.Format("default({0})", GetRedPropertyType(field));
}
else if (field.Type == "SyntaxToken")
{
// auto construct token?
if (field.Kinds.Count == 1)
{
return string.Format("SyntaxFactory.Token(SyntaxKind.{0})", field.Kinds[0].Name);
}
else
{
return string.Format("SyntaxFactory.Token(Get{0}{1}Kind(kind))", StripPost(nd.Name, "Syntax"), StripPost(field.Name, "Opt"));
}
}
else
{
var referencedNode = GetNode(field.Type);
return string.Format("SyntaxFactory.{0}()", StripPost(referencedNode.Name, "Syntax"));
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:26,代码来源:SourceWriter.cs
示例9: WriteRedListHelperMethods
private void WriteRedListHelperMethods(Node node, Field field)
{
var argType = GetElementType(field.Type);
WriteLine();
WriteLine(" public {0} Add{1}(params {2}[] items)", node.Name, field.Name, argType);
WriteLine(" {");
WriteLine(" return this.With{0}(this.{1}.AddRange(items));", StripPost(field.Name, "Opt"), field.Name);
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:9,代码来源:SourceWriter.cs
示例10: WriteRedSetters
private void WriteRedSetters(Node node)
{
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
var type = this.GetRedPropertyType(field);
WriteLine();
WriteLine(" {0} {1} With{2}({3} {4})", "public", node.Name, StripPost(field.Name, "Opt"), type, CamelCase(field.Name));
WriteLine(" {");
// call update inside each setter
Write(" return this.Update(");
for (int f2 = 0; f2 < node.Fields.Count; f2++)
{
var field2 = node.Fields[f2];
if (f2 > 0)
Write(", ");
if (field2 == field)
{
this.Write("{0}", CamelCase(field2.Name));
}
else
{
this.Write("this.{0}", field2.Name);
}
}
WriteLine(");");
WriteLine(" }");
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:33,代码来源:SourceWriter.cs
示例11: WriteRedWithMethod
private void WriteRedWithMethod(Node node)
{
WriteLine();
Write(" public {0} With(", node.Name);
// parameters
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
var type = this.GetRedPropertyType(field);
Write("Optional<{0}> {1} = default(Optional<{0}>)", type, CamelCase(field.Name));
if (f < node.Fields.Count - 1)
Write(", ");
}
WriteLine(")");
WriteLine(" {");
Write(" return this.Update(");
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
var parameterName = CamelCase(field.Name);
WriteLine();
Write(" {0}.HasValue ? {0}.Value : this.{1}", parameterName, field.Name);
if (f < node.Fields.Count - 1)
Write(",");
}
WriteLine();
WriteLine(" );");
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:34,代码来源:SourceWriter.cs
示例12: WriteRedUpdateMethod
private void WriteRedUpdateMethod(Node node)
{
WriteLine();
Write(" {0} {1} Update(", "public", node.Name);
// parameters
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
if (f > 0)
Write(", ");
var type = field.Type == "SyntaxList<SyntaxToken>" ? "SyntaxTokenList" : field.Type;
Write("{0} {1}", type, CamelCase(field.Name));
}
WriteLine(")");
WriteLine(" {");
Write(" if (");
int nCompared = 0;
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
if (IsDerivedOrListOfDerived("SyntaxNode", field.Type) || IsDerivedOrListOfDerived("SyntaxToken", field.Type) || field.Type == "SyntaxNodeOrTokenList")
{
if (nCompared > 0)
Write(" || ");
Write("{0} != this.{1}", CamelCase(field.Name), field.Name);
nCompared++;
}
}
if (nCompared > 0)
{
WriteLine(")");
WriteLine(" {");
Write(" var newNode = SyntaxFactory.{0}(", StripPost(node.Name, "Syntax"));
if (node.Kinds.Count > 1)
{
Write("this.Kind(), ");
}
for (int f = 0; f < node.Fields.Count; f++)
{
var field = node.Fields[f];
if (f > 0)
Write(", ");
Write(CamelCase(field.Name));
}
WriteLine(");");
WriteLine(" var annotations = this.GetAnnotations();");
WriteLine(" if (annotations != null && annotations.Length > 0)");
WriteLine(" return newNode.WithAnnotations(annotations);");
WriteLine(" return newNode;");
WriteLine(" }");
}
WriteLine();
WriteLine(" return this;");
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:58,代码来源:SourceWriter.cs
示例13: WriteRedAcceptMethod
private void WriteRedAcceptMethod(Node node, bool genericArgument, bool genericResult)
{
string genericArgs =
(genericResult && genericArgument) ? "<TArgument, TResult>" :
genericResult ? "<TResult>" : "";
WriteLine();
WriteLine(" public override " + (genericResult ? "TResult" : "void") + " Accept" + genericArgs + "(CSharpSyntaxVisitor" + genericArgs + " visitor{0})", genericArgument ? ", TArgument argument" : "");
WriteLine(" {");
WriteLine(" " + (genericResult ? "return " : "") + "visitor.Visit{0}(this{1});", StripPost(node.Name, "Syntax"), genericArgument ? ", argument" : "");
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:SourceWriter.cs
示例14: WriteRedAcceptMethods
private void WriteRedAcceptMethods(Node node)
{
//WriteRedAcceptMethod(node, true, true);
WriteRedAcceptMethod(node, false, true);
WriteRedAcceptMethod(node, false, false);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:6,代码来源:SourceWriter.cs
示例15: WriteRedFactory
// full factory signature with nothing optional
private void WriteRedFactory(Node nd)
{
this.WriteLine();
var valueFields = nd.Fields.Where(n => IsValueField(n)).ToList();
var nodeFields = nd.Fields.Where(n => !IsValueField(n)).ToList();
WriteComment(string.Format("<summary>Creates a new {0} instance.</summary>", nd.Name), " ");
Write(" {0} static {1} {2}(", "public", nd.Name, StripPost(nd.Name, "Syntax"));
WriteRedFactoryParameters(nd);
WriteLine(")");
WriteLine(" {");
// validate kinds
if (nd.Kinds.Count > 1)
{
WriteLine(" switch (kind)");
WriteLine(" {");
foreach (var kind in nd.Kinds)
{
WriteLine(" case SyntaxKind.{0}:", kind.Name);
}
WriteLine(" break;");
WriteLine(" default:");
WriteLine(" throw new ArgumentException(\"kind\");");
WriteLine(" }");
}
// validate parameters
for (int i = 0, n = nodeFields.Count; i < n; i++)
{
var field = nodeFields[i];
var pname = CamelCase(field.Name);
if (field.Type == "SyntaxToken")
{
if (field.Kinds != null && field.Kinds.Count > 0)
{
WriteLine(" switch ({0}.Kind())", pname);
WriteLine(" {");
foreach (var kind in field.Kinds)
{
WriteLine(" case SyntaxKind.{0}:", kind.Name);
}
if (IsOptional(field))
{
WriteLine(" case SyntaxKind.None:");
}
WriteLine(" break;");
WriteLine(" default:");
WriteLine(" throw new ArgumentException(\"{0}\");", pname);
WriteLine(" }");
}
}
else if (!IsAnyList(field.Type) && !IsOptional(field))
{
WriteLine(" if ({0} == null)", CamelCase(field.Name));
WriteLine(" throw new ArgumentNullException(nameof({0}));", CamelCase(field.Name));
}
}
Write(" return ({0})Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxFactory.{1}(", nd.Name, StripPost(nd.Name, "Syntax"));
if (nd.Kinds.Count > 1)
{
Write("kind, ");
}
for (int i = 0, n = nodeFields.Count; i < n; i++)
{
var field = nodeFields[i];
if (i > 0)
Write(", ");
if (field.Type == "SyntaxToken")
{
Write("(Syntax.InternalSyntax.SyntaxToken){0}.Node", CamelCase(field.Name));
}
else if (field.Type == "SyntaxList<SyntaxToken>")
{
Write("{0}.Node.ToGreenList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken>()", CamelCase(field.Name));
}
else if (IsNodeList(field.Type))
{
Write("{0}.Node.ToGreenList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.{1}>()", CamelCase(field.Name), GetElementType(field.Type));
}
else if (IsSeparatedNodeList(field.Type))
{
Write("{0}.Node.ToGreenSeparatedList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.{1}>()", CamelCase(field.Name), GetElementType(field.Type));
}
else if (field.Type == "SyntaxNodeOrTokenList")
{
Write("{0}.Node.ToGreenList<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CSharpSyntaxNode>()", CamelCase(field.Name));
}
else
{
Write("{0} == null ? null : (Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.{1}){0}.Green", CamelCase(field.Name), field.Type);
}
}
//.........这里部分代码省略.........
开发者ID:XieShuquan,项目名称:roslyn,代码行数:101,代码来源:SourceWriter.cs
示例16: WriteRedFactoryParameters
private void WriteRedFactoryParameters(Node nd)
{
if (nd.Kinds.Count > 1)
{
Write("SyntaxKind kind, ");
}
for (int i = 0, n = nd.Fields.Count; i < n; i++)
{
var field = nd.Fields[i];
if (i > 0)
Write(", ");
var type = this.GetRedPropertyType(field);
Write("{0} {1}", type, CamelCase(field.Name));
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:17,代码来源:SourceWriter.cs
示例17: WriteRedNestedListHelperMethods
private void WriteRedNestedListHelperMethods(Node node, Field field, Node referencedNode, Field referencedNodeField)
{
var argType = GetElementType(referencedNodeField.Type);
// AddBaseListTypes
WriteLine();
WriteLine(" public {0} Add{1}{2}(params {3}[] items)", node.Name, StripPost(field.Name, "Opt"), referencedNodeField.Name, argType);
WriteLine(" {");
if (IsOptional(field))
{
var factoryName = StripPost(referencedNode.Name, "Syntax");
var varName = StripPost(CamelCase(field.Name), "Opt");
WriteLine(" var {0} = this.{1} ?? SyntaxFactory.{2}();", varName, field.Name, factoryName);
WriteLine(" return this.With{0}({1}.With{2}({1}.{3}.AddRange(items)));", StripPost(field.Name, "Opt"), varName, StripPost(referencedNodeField.Name, "Opt"), referencedNodeField.Name);
}
else
{
WriteLine(" return this.With{0}(this.{1}.With{2}(this.{1}.{3}.AddRange(items)));", StripPost(field.Name, "Opt"), field.Name, StripPost(referencedNodeField.Name, "Opt"), referencedNodeField.Name);
}
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:23,代码来源:SourceWriter.cs
示例18: WriteKindConverters
// Writes Get<Property>Kind() methods for converting between node kind and member token kinds...
private void WriteKindConverters(Node nd)
{
for (int f = 0; f < nd.Fields.Count; f++)
{
var field = nd.Fields[f];
if (field.Type == "SyntaxToken" && CanBeAutoCreated(nd, field) && field.Kinds.Count > 1)
{
WriteLine();
WriteLine(" private static SyntaxKind Get{0}{1}Kind(SyntaxKind kind)", StripPost(nd.Name, "Syntax"), StripPost(field.Name, "Opt"));
WriteLine(" {");
WriteLine(" switch (kind)");
WriteLine(" {");
for (int k = 0; k < field.Kinds.Count; k++)
{
var nKind = nd.Kinds[k];
var pKind = field.Kinds[k];
WriteLine(" case SyntaxKind.{0}:", nKind.Name);
WriteLine(" return SyntaxKind.{0};", pKind.Name);
}
WriteLine(" default:");
WriteLine(" throw new ArgumentOutOfRangeException();");
WriteLine(" }");
WriteLine(" }");
}
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:31,代码来源:SourceWriter.cs
示例19: CanBeAutoCreated
protected bool CanBeAutoCreated(Node node, Field field)
{
return IsAutoCreatableToken(node, field) || IsAutoCreatableNode(node, field);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:4,代码来源:SourceWriter.cs
示例20: WriteRedFactoryWithNoAutoCreatableTokens
// creates a factory without auto-creatable token arguments
private void WriteRedFactoryWithNoAutoCreatableTokens(Node nd)
{
var nAutoCreatableTokens = nd.Fields.Count(f => IsAutoCreatableToken(nd, f));
if (nAutoCreatableTokens == 0)
return; // already handled by general factory
var factoryWithNoAutoCreatableTokenFields = new HashSet<Field>(DetermineRedFactoryWithNoAutoCreatableTokenFields(nd));
var minimalFactoryFields = DetermineMinimalFactoryFields(nd);
if (minimalFactoryFields != null && factoryWithNoAutoCreatableTokenFields.SetEquals(minimalFactoryFields))
{
return; // will be handled in minimal factory case
}
this.WriteLine();
WriteComment(string.Format("<summary>Creates a new {0} instance.</summary>", nd.Name), " ");
Write(" {0} static {1} {2}(", "public", nd.Name, StripPost(nd.Name, "Syntax"));
bool hasPreviousParameter = false;
if (nd.Kinds.Count > 1)
{
Write("SyntaxKind kind");
hasPreviousParameter = true;
}
for (int i = 0, n = nd.Fields.Count; i < n; i++)
{
var field = nd.Fields[i];
if (factoryWithNoAutoCreatableTokenFields.Contains(field))
{
if (hasPreviousParameter)
Write(", ");
Write("{0} {1}", GetRedPropertyType(field), CamelCase(field.Name));
hasPreviousParameter = true;
}
}
WriteLine(")");
WriteLine(" {");
Write(" return SyntaxFactory.{0}(", StripPost(nd.Name, "Syntax"));
bool hasPreviousArgument = false;
if (nd.Kinds.Count > 1)
{
Write("kind");
hasPreviousArgument = true;
}
for (int i = 0, n = nd.Fields.Count; i < n; i++)
{
var field = nd.Fields[i];
if (hasPreviousArgument)
Write(", ");
if (factoryWithNoAutoCreatableTokenFields.Contains(field))
{
// pass supplied parameter on to general factory
Write("{0}", CamelCase(field.Name));
}
else
{
// pass an auto-created token to the general factory
Write("{0}", GetDefaultValue(nd, field));
}
hasPreviousArgument = true;
}
WriteLine(");");
WriteLine(" }");
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:78,代码来源:SourceWriter.cs
注:本文中的CSharpSyntaxGenerator.Node类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论