Free cookie consent management tool by TermsFeed Policy Generator

source: branches/MemPRAlgorithm/HeuristicLab.ExtLibs/HeuristicLab.AvalonEdit/5.0.1/AvalonEdit-5.0.1/Document/TextDocumentWeakEventManager.cs @ 14808

Last change on this file since 14808 was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 5.7 KB
Line 
1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4// software and associated documentation files (the "Software"), to deal in the Software
5// without restriction, including without limitation the rights to use, copy, modify, merge,
6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7// to whom the Software is furnished to do so, subject to the following conditions:
8//
9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11//
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20#if NREFACTORY
21using ICSharpCode.NRefactory.Editor;
22#endif
23using ICSharpCode.AvalonEdit.Utils;
24
25namespace ICSharpCode.AvalonEdit.Document
26{
27  /// <summary>
28  /// Contains weak event managers for the TextDocument events.
29  /// </summary>
30  public static class TextDocumentWeakEventManager
31  {
32    /// <summary>
33    /// Weak event manager for the <see cref="TextDocument.UpdateStarted"/> event.
34    /// </summary>
35    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
36    public sealed class UpdateStarted : WeakEventManagerBase<UpdateStarted, TextDocument>
37    {
38      /// <inheritdoc/>
39      protected override void StartListening(TextDocument source)
40      {
41        source.UpdateStarted += DeliverEvent;
42      }
43     
44      /// <inheritdoc/>
45      protected override void StopListening(TextDocument source)
46      {
47        source.UpdateStarted -= DeliverEvent;
48      }
49    }
50   
51    /// <summary>
52    /// Weak event manager for the <see cref="TextDocument.UpdateFinished"/> event.
53    /// </summary>
54    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
55    public sealed class UpdateFinished : WeakEventManagerBase<UpdateFinished, TextDocument>
56    {
57      /// <inheritdoc/>
58      protected override void StartListening(TextDocument source)
59      {
60        source.UpdateFinished += DeliverEvent;
61      }
62     
63      /// <inheritdoc/>
64      protected override void StopListening(TextDocument source)
65      {
66        source.UpdateFinished -= DeliverEvent;
67      }
68    }
69   
70    /// <summary>
71    /// Weak event manager for the <see cref="TextDocument.Changing"/> event.
72    /// </summary>
73    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
74    public sealed class Changing : WeakEventManagerBase<Changing, TextDocument>
75    {
76      /// <inheritdoc/>
77      protected override void StartListening(TextDocument source)
78      {
79        source.Changing += DeliverEvent;
80      }
81     
82      /// <inheritdoc/>
83      protected override void StopListening(TextDocument source)
84      {
85        source.Changing -= DeliverEvent;
86      }
87    }
88   
89    /// <summary>
90    /// Weak event manager for the <see cref="TextDocument.Changed"/> event.
91    /// </summary>
92    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
93    public sealed class Changed : WeakEventManagerBase<Changed, TextDocument>
94    {
95      /// <inheritdoc/>
96      protected override void StartListening(TextDocument source)
97      {
98        source.Changed += DeliverEvent;
99      }
100     
101      /// <inheritdoc/>
102      protected override void StopListening(TextDocument source)
103      {
104        source.Changed -= DeliverEvent;
105      }
106    }
107   
108    /// <summary>
109    /// Weak event manager for the <see cref="TextDocument.LineCountChanged"/> event.
110    /// </summary>
111    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
112    [Obsolete("The TextDocument.LineCountChanged event will be removed in a future version. Use PropertyChangedEventManager instead.")]
113    public sealed class LineCountChanged : WeakEventManagerBase<LineCountChanged, TextDocument>
114    {
115      /// <inheritdoc/>
116      protected override void StartListening(TextDocument source)
117      {
118        source.LineCountChanged += DeliverEvent;
119      }
120     
121      /// <inheritdoc/>
122      protected override void StopListening(TextDocument source)
123      {
124        source.LineCountChanged -= DeliverEvent;
125      }
126    }
127   
128    /// <summary>
129    /// Weak event manager for the <see cref="TextDocument.TextLengthChanged"/> event.
130    /// </summary>
131    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
132    [Obsolete("The TextDocument.TextLengthChanged event will be removed in a future version. Use PropertyChangedEventManager instead.")]
133    public sealed class TextLengthChanged : WeakEventManagerBase<TextLengthChanged, TextDocument>
134    {
135      /// <inheritdoc/>
136      protected override void StartListening(TextDocument source)
137      {
138        source.TextLengthChanged += DeliverEvent;
139      }
140     
141      /// <inheritdoc/>
142      protected override void StopListening(TextDocument source)
143      {
144        source.TextLengthChanged -= DeliverEvent;
145      }
146    }
147   
148    /// <summary>
149    /// Weak event manager for the <see cref="TextDocument.TextChanged"/> event.
150    /// </summary>
151    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
152    public sealed class TextChanged : WeakEventManagerBase<TextChanged, TextDocument>
153    {
154      /// <inheritdoc/>
155      protected override void StartListening(TextDocument source)
156      {
157        source.TextChanged += DeliverEvent;
158      }
159     
160      /// <inheritdoc/>
161      protected override void StopListening(TextDocument source)
162      {
163        source.TextChanged -= DeliverEvent;
164      }
165    }
166  }
167}
Note: See TracBrowser for help on using the repository browser.