public override void WriteComment(string text)
{
if (IsClosed)
ThrowClosed();
if (_writeState == WriteState.Attribute)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidWriteState, "WriteComment", WriteState.ToString())));
if (text == null)
{
text = string.Empty;
}
else if (text.IndexOf("--", StringComparison.Ordinal) != -1 || (text.Length > 0 && text[text.Length - 1] == '-'))
{
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlInvalidCommentChars), nameof(text)));
}
StartComment();
FlushBase64();
_writer.WriteComment(text);
EndComment();
}