internal static void WriteExpressionToXml(this XmlWriter writer, IMorestachioExpression morestachioExpression) { switch (morestachioExpression) { case MorestachioExpression _: writer.WriteStartElement("Expression"); break; case MorestachioArgumentExpressionList _: writer.WriteStartElement("ExpressionArgList"); break; case MorestachioMultiPartExpressionList _: writer.WriteStartElement("ExpressionMultiPart"); break; case MorestachioExpressionString _: writer.WriteStartElement("ExpressionString"); break; case MorestachioExpressionNumber _: writer.WriteStartElement("ExpressionNumber"); break; case MorestachioOperatorExpression _: writer.WriteStartElement("ExpressionOperator"); break; default: throw new ArgumentOutOfRangeException(nameof(morestachioExpression)); } morestachioExpression.WriteXml(writer); writer.WriteEndElement(); }
internal static void WriteExpressionToXml(this XmlWriter writer, IMorestachioExpression morestachioExpression) { writer.WriteStartElement(ExpressionNodeName); switch (morestachioExpression) { case MorestachioExpression expression1: writer.WriteAttributeString(ExpressionKindNodeName, "Expression"); break; case MorestachioExpressionList expressionList: writer.WriteAttributeString(ExpressionKindNodeName, "ExpressionList"); break; case MorestachioExpressionString expressionString: writer.WriteAttributeString(ExpressionKindNodeName, "ExpressionString"); break; default: throw new ArgumentOutOfRangeException(nameof(morestachioExpression)); } morestachioExpression.WriteXml(writer); writer.WriteEndElement(); }