Questionable/QuestPathGenerator/RoslynElements/PurchaseMenuExtensions.cs

29 lines
1.2 KiB
C#
Raw Permalink Normal View History

2024-09-23 18:32:54 +00:00
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Questionable.Model.Questing;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using static Questionable.QuestPathGenerator.RoslynShortcuts;
namespace Questionable.QuestPathGenerator.RoslynElements;
internal static class PurchaseMenuExtensions
{
public static ExpressionSyntax ToExpressionSyntax(this PurchaseMenu purchaseMenu)
{
PurchaseMenu emptyMenu = new();
return ObjectCreationExpression(
IdentifierName(nameof(PurchaseMenu)))
.WithInitializer(
InitializerExpression(
SyntaxKind.ObjectInitializerExpression,
SeparatedList<ExpressionSyntax>(
SyntaxNodeList(
Assignment(nameof(PurchaseMenu.ExcelSheet), purchaseMenu.ExcelSheet,
emptyMenu.ExcelSheet)
.AsSyntaxNodeOrToken(),
Assignment(nameof(PurchaseMenu.Key), purchaseMenu.Key,
emptyMenu.Key)
.AsSyntaxNodeOrToken()))));
}
}