~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/Mono.Texteditor/Mono.TextEditor/Standalone/TextChangeEventArgs.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
17
// DEALINGS IN THE SOFTWARE.
18
18
#if STANDALONE
 
19
 
19
20
using System;
20
21
 
21
22
namespace ICSharpCode.NRefactory.Editor
28
29
        public class TextChangeEventArgs : EventArgs
29
30
        {
30
31
                readonly int offset;
31
 
                readonly string removedText;
32
 
                readonly string insertedText;
 
32
                readonly ITextSource removedText;
 
33
                readonly ITextSource insertedText;
33
34
                
34
35
                /// <summary>
35
36
                /// The offset at which the change occurs.
41
42
                /// <summary>
42
43
                /// The text that was removed.
43
44
                /// </summary>
44
 
                public string RemovedText {
 
45
                public ITextSource RemovedText {
45
46
                        get { return removedText; }
46
47
                }
47
48
                
49
50
                /// The number of characters removed.
50
51
                /// </summary>
51
52
                public int RemovalLength {
52
 
                        get { return removedText.Length; }
 
53
                        get { return removedText.TextLength; }
53
54
                }
54
55
                
55
56
                /// <summary>
56
57
                /// The text that was inserted.
57
58
                /// </summary>
58
 
                public string InsertedText {
 
59
                public ITextSource InsertedText {
59
60
                        get { return insertedText; }
60
61
                }
61
62
                
63
64
                /// The number of characters inserted.
64
65
                /// </summary>
65
66
                public int InsertionLength {
66
 
                        get { return insertedText.Length; }
 
67
                        get { return insertedText.TextLength; }
67
68
                }
68
69
                
69
70
                /// <summary>
71
72
                /// </summary>
72
73
                public TextChangeEventArgs(int offset, string removedText, string insertedText)
73
74
                {
74
 
                        this.offset = offset;
75
 
                        this.removedText = removedText ?? string.Empty;
76
 
                        this.insertedText = insertedText ?? string.Empty;
 
75
                        if (offset < 0)
 
76
                                throw new ArgumentOutOfRangeException("offset", offset, "offset must not be negative");
 
77
                        this.offset = offset;
 
78
                        this.removedText = removedText != null ? new StringTextSource(removedText) : StringTextSource.Empty;
 
79
                        this.insertedText = insertedText != null ? new StringTextSource(insertedText) : StringTextSource.Empty;
 
80
                }
 
81
                
 
82
                /// <summary>
 
83
                /// Creates a new TextChangeEventArgs object.
 
84
                /// </summary>
 
85
                public TextChangeEventArgs(int offset, ITextSource removedText, ITextSource insertedText)
 
86
                {
 
87
                        if (offset < 0)
 
88
                                throw new ArgumentOutOfRangeException("offset", offset, "offset must not be negative");
 
89
                        this.offset = offset;
 
90
                        this.removedText = removedText ?? StringTextSource.Empty;
 
91
                        this.insertedText = insertedText ?? StringTextSource.Empty;
77
92
                }
78
93
                
79
94
                /// <summary>
102
117
                }
103
118
        }
104
119
}
 
120
 
105
121
#endif
 
 
b'\\ No newline at end of file'