Questionable/QuestPathGenerator/RoslynElements/GatheringNodeGroupExtensions.cs

24 lines
933 B
C#
Raw Permalink Normal View History

2024-08-17 18:59:42 +00:00
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()))));
}
}