Questionable/QuestPathGenerator/RoslynElements/GatheringNodeGroupExtensions.cs
2024-08-17 21:01:46 +02:00

24 lines
933 B
C#

using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Questionable.Model.Gathering;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using static Questionable.QuestPathGenerator.RoslynShortcuts;
namespace Questionable.QuestPathGenerator.RoslynElements;
internal static class GatheringNodeGroupExtensions
{
public static ExpressionSyntax ToExpressionSyntax(this GatheringNodeGroup nodeGroup)
{
return ObjectCreationExpression(
IdentifierName(nameof(GatheringNodeGroup)))
.WithInitializer(
InitializerExpression(
SyntaxKind.ObjectInitializerExpression,
SeparatedList<ExpressionSyntax>(
SyntaxNodeList(
AssignmentList(nameof(GatheringNodeGroup.Nodes), nodeGroup.Nodes)
.AsSyntaxNodeOrToken()))));
}
}