/// <summary> /// Deserializes text into XLIFF elements under the specified source element. /// </summary> /// <param name="source">The element to deserialize content to.</param> /// <param name="text">The text to deserialize.</param> public static void DeserializeText(XliffElement source, string text) { XliffReader reader; reader = new XliffReader(); reader.currentElementState = new ElementState(source); using (MemoryStream stream = new MemoryStream()) { // Don't wrap this in using because it may dispose of the stream which is one too many. TextWriter writer; writer = new StreamWriter(stream); writer.Write(text); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); reader.reader = XmlReader.Create(stream); reader.DeserializeXmlContent(source); } }