XML deserialization 'standardising' line endings, how to stop it? (.NET)

后端 未结 2 1668
栀梦
栀梦 2020-12-06 18:14

I have a class with a property marked with [XmlText], that accepts multiline input. In my XML file, I\'ve verified that the line endings inside the text content

2条回答
  •  无人及你
    2020-12-06 18:35

    If you were serializing, then XmlWriterSettings.NewLineHandling (Replace) would be worth trying - but this won't help reading. A bit grungy, but perhaps do this directly in the setter:

    private string text;
    [XmlText]
    public string Text {
        get { return text; }
        set 
        {
            Regex r = new Regex("(?

提交回复
热议问题