PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlText.cs

http://github.com/icsharpcode/ILSpy
C# | 62 lines | 44 code | 6 blank | 12 comment | 5 complexity | 7f4c2de1fe09e5456097c831d6f74ceb MD5 | raw file
 1// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 2// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Collections.ObjectModel;
 7using System.Collections.Specialized;
 8using System.Diagnostics;
 9using System.Globalization;
10using System.Linq;
11
12using ICSharpCode.AvalonEdit.Document;
13
14namespace ICSharpCode.AvalonEdit.Xml
15{
16	/// <summary>
17	/// Whitespace or character data
18	/// </summary>
19	public class AXmlText: AXmlObject
20	{
21		/// <summary> The context in which the text occured </summary>
22		internal TextType Type { get; set; }
23		/// <summary> The text exactly as in source </summary>
24		public string EscapedValue { get; set; }
25		/// <summary> The text with all entity references resloved </summary>
26		public string Value { get; set; }
27		/// <summary> True if the text contains only whitespace characters </summary>
28		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Whitespace",
29		                                                 Justification = "System.Xml also uses 'Whitespace'")]
30		public bool ContainsOnlyWhitespace { get; set; }
31		
32		/// <inheritdoc/>
33		public override void AcceptVisitor(IAXmlVisitor visitor)
34		{
35			visitor.VisitText(this);
36		}
37		
38		/// <inheritdoc/>
39		internal override bool UpdateDataFrom(AXmlObject source)
40		{
41			if (!base.UpdateDataFrom(source)) return false;
42			AXmlText src = (AXmlText)source;
43			if (this.EscapedValue != src.EscapedValue ||
44			    this.Value != src.Value)
45			{
46				OnChanging();
47				this.EscapedValue = src.EscapedValue;
48				this.Value = src.Value;
49				OnChanged();
50				return true;
51			} else {
52				return false;
53			}
54		}
55		
56		/// <inheritdoc/>
57		public override string ToString()
58		{
59			return string.Format(CultureInfo.InvariantCulture, "[{0} Text.Length={1}]", base.ToString(), this.EscapedValue.Length);
60		}
61	}
62}