Mercurial > pub > bltoolkit
comparison Source/Common/Compatibility3.cs @ 0:f990fcb411a9
Копия текущей версии из github
| author | cin |
|---|---|
| date | Thu, 27 Mar 2014 21:46:09 +0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f990fcb411a9 |
|---|---|
| 1 #if FW2 | |
| 2 | |
| 3 namespace System | |
| 4 { | |
| 5 public delegate void Action(); | |
| 6 | |
| 7 public delegate void Action<T1, T2>(T1 arg1, T2 arg2); | |
| 8 | |
| 9 public delegate void Action<T1, T2, T3>(T1 arg1, T2 arg2, T3 arg3); | |
| 10 | |
| 11 public delegate void Action<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4); | |
| 12 | |
| 13 public delegate TResult Func<TResult>(); | |
| 14 | |
| 15 public delegate TResult Func<T1, TResult>(T1 arg1); | |
| 16 | |
| 17 public delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2); | |
| 18 | |
| 19 public delegate TResult Func<T1, T2, T3, TResult>(T1 arg1, T2 arg2, T3 arg3); | |
| 20 | |
| 21 public delegate TResult Func<T1, T2, T3, T4, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4); | |
| 22 } | |
| 23 | |
| 24 namespace System.Collections.Specialized | |
| 25 { | |
| 26 public interface INotifyCollectionChanged | |
| 27 { | |
| 28 event NotifyCollectionChangedEventHandler CollectionChanged; | |
| 29 } | |
| 30 | |
| 31 /// <summary> | |
| 32 /// This enum describes the action that caused a CollectionChanged event. | |
| 33 /// </summary> | |
| 34 public enum NotifyCollectionChangedAction | |
| 35 { | |
| 36 /// <summary> One or more items were added to the collection. </summary> | |
| 37 Add, | |
| 38 /// <summary> One or more items were removed from the collection. </summary> | |
| 39 Remove, | |
| 40 /// <summary> One or more items were replaced in the collection. </summary> | |
| 41 Replace, | |
| 42 /// <summary> One or more items were moved within the collection. </summary> | |
| 43 Move, | |
| 44 /// <summary> The contents of the collection changed dramatically. </summary> | |
| 45 Reset, | |
| 46 } | |
| 47 | |
| 48 /// <summary> | |
| 49 /// Arguments for the CollectionChanged event. A collection that supports | |
| 50 /// INotifyCollectionChangedThis raises this event whenever an item is added or | |
| 51 /// removed, or when the contents of the collection changes dramatically. | |
| 52 /// </summary> | |
| 53 public class NotifyCollectionChangedEventArgs : EventArgs | |
| 54 { | |
| 55 #region .ctors | |
| 56 | |
| 57 /// <summary> | |
| 58 /// Construct a NotifyCollectionChangedEventArgs that describes a reset change. | |
| 59 /// </summary> | |
| 60 /// <param name="action">The action that caused the event (must be Reset).</param> | |
| 61 public NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction action) | |
| 62 : this(action, null, -1) | |
| 63 { | |
| 64 } | |
| 65 | |
| 66 /// <summary> | |
| 67 /// Construct a NotifyCollectionChangedEventArgs that describes a one-item change. | |
| 68 /// </summary> | |
| 69 /// <param name="action">The action that caused the event; can only be Reset, Add or Remove action.</param> | |
| 70 /// <param name="changedItem">The item affected by the change.</param> | |
| 71 public NotifyCollectionChangedEventArgs( | |
| 72 NotifyCollectionChangedAction action, | |
| 73 object changedItem) | |
| 74 : this(action, changedItem, -1) | |
| 75 { | |
| 76 } | |
| 77 | |
| 78 /// <summary> | |
| 79 /// Construct a NotifyCollectionChangedEventArgs that describes a one-item change. | |
| 80 /// </summary> | |
| 81 /// <param name="action">The action that caused the event.</param> | |
| 82 /// <param name="changedItem">The item affected by the change.</param> | |
| 83 /// <param name="index">The index where the change occurred.</param> | |
| 84 public NotifyCollectionChangedEventArgs( | |
| 85 NotifyCollectionChangedAction action, | |
| 86 object changedItem, | |
| 87 int index) | |
| 88 : this(action, changedItem == null? null: new[]{ changedItem }, index) | |
| 89 { | |
| 90 } | |
| 91 | |
| 92 /// <summary> | |
| 93 /// Construct a NotifyCollectionChangedEventArgs that describes a multi-item change. | |
| 94 /// </summary> | |
| 95 /// <param name="action">The action that caused the event.</param> | |
| 96 /// <param name="changedItems">The items affected by the change.</param> | |
| 97 public NotifyCollectionChangedEventArgs( | |
| 98 NotifyCollectionChangedAction action, | |
| 99 IList changedItems) | |
| 100 : this(action, changedItems, -1) | |
| 101 { | |
| 102 } | |
| 103 | |
| 104 /// <summary> | |
| 105 /// Construct a NotifyCollectionChangedEventArgs that describes a multi-item change (or a reset). | |
| 106 /// </summary> | |
| 107 /// <param name="action">The action that caused the event.</param> | |
| 108 /// <param name="changedItems">The items affected by the change.</param> | |
| 109 /// <param name="startingIndex">The index where the change occurred.</param> | |
| 110 public NotifyCollectionChangedEventArgs( | |
| 111 NotifyCollectionChangedAction action, | |
| 112 IList changedItems, | |
| 113 int startingIndex) | |
| 114 { | |
| 115 _action = action; | |
| 116 | |
| 117 if (action == NotifyCollectionChangedAction.Add) | |
| 118 { | |
| 119 _newItems = changedItems; | |
| 120 _newStartingIndex = startingIndex; | |
| 121 } | |
| 122 else if (action == NotifyCollectionChangedAction.Remove) | |
| 123 { | |
| 124 _oldItems = changedItems; | |
| 125 _oldStartingIndex = startingIndex; | |
| 126 } | |
| 127 } | |
| 128 | |
| 129 /// <summary> | |
| 130 /// Construct a NotifyCollectionChangedEventArgs that describes a one-item Replace event. | |
| 131 /// </summary> | |
| 132 /// <param name="action">Can only be a Replace action.</param> | |
| 133 /// <param name="newItem">The new item replacing the original item.</param> | |
| 134 /// <param name="oldItem">The original item that is replaced.</param> | |
| 135 public NotifyCollectionChangedEventArgs( | |
| 136 NotifyCollectionChangedAction action, | |
| 137 object newItem, | |
| 138 object oldItem) | |
| 139 : this(action, new[] { newItem }, new[] { oldItem }, -1) | |
| 140 { | |
| 141 } | |
| 142 | |
| 143 /// <summary> | |
| 144 /// Construct a NotifyCollectionChangedEventArgs that describes a one-item Replace event. | |
| 145 /// </summary> | |
| 146 /// <param name="action">Can only be a Replace action.</param> | |
| 147 /// <param name="newItem">The new item replacing the original item.</param> | |
| 148 /// <param name="oldItem">The original item that is replaced.</param> | |
| 149 /// <param name="index">The index of the item being replaced.</param> | |
| 150 public NotifyCollectionChangedEventArgs( | |
| 151 NotifyCollectionChangedAction action, | |
| 152 object newItem, | |
| 153 object oldItem, | |
| 154 int index) | |
| 155 : this(action, new[] { newItem }, new[] { oldItem }, index) | |
| 156 { | |
| 157 } | |
| 158 | |
| 159 /// <summary> | |
| 160 /// Construct a NotifyCollectionChangedEventArgs that describes a multi-item Replace event. | |
| 161 /// </summary> | |
| 162 /// <param name="action">Can only be a Replace action.</param> | |
| 163 /// <param name="newItems">The new items replacing the original items.</param> | |
| 164 /// <param name="oldItems">The original items that are replaced.</param> | |
| 165 public NotifyCollectionChangedEventArgs( | |
| 166 NotifyCollectionChangedAction action, | |
| 167 IList newItems, | |
| 168 IList oldItems) | |
| 169 : this(action, newItems, oldItems, -1) | |
| 170 { | |
| 171 } | |
| 172 | |
| 173 /// <summary> | |
| 174 /// Construct a NotifyCollectionChangedEventArgs that describes a multi-item Replace event. | |
| 175 /// </summary> | |
| 176 /// <param name="action">Can only be a Replace action.</param> | |
| 177 /// <param name="newItems">The new items replacing the original items.</param> | |
| 178 /// <param name="oldItems">The original items that are replaced.</param> | |
| 179 /// <param name="startingIndex">The starting index of the items being replaced.</param> | |
| 180 public NotifyCollectionChangedEventArgs( | |
| 181 NotifyCollectionChangedAction action, | |
| 182 IList newItems, | |
| 183 IList oldItems, | |
| 184 int startingIndex) | |
| 185 { | |
| 186 _action = action; | |
| 187 | |
| 188 _newItems = newItems; | |
| 189 _newStartingIndex = startingIndex; | |
| 190 _oldItems = oldItems; | |
| 191 _oldStartingIndex = startingIndex; | |
| 192 } | |
| 193 | |
| 194 /// <summary> | |
| 195 /// Construct a NotifyCollectionChangedEventArgs that describes a one-item Move event. | |
| 196 /// </summary> | |
| 197 /// <param name="action">Can only be a Move action.</param> | |
| 198 /// <param name="changedItem">The item affected by the change.</param> | |
| 199 /// <param name="index">The new index for the changed item.</param> | |
| 200 /// <param name="oldIndex">The old index for the changed item.</param> | |
| 201 public NotifyCollectionChangedEventArgs( | |
| 202 NotifyCollectionChangedAction action, | |
| 203 object changedItem, | |
| 204 int index, | |
| 205 int oldIndex) | |
| 206 : this(action, new[]{changedItem}, index, oldIndex) | |
| 207 { | |
| 208 } | |
| 209 | |
| 210 /// <summary> | |
| 211 /// Construct a NotifyCollectionChangedEventArgs that describes a multi-item Move event. | |
| 212 /// </summary> | |
| 213 /// <param name="action">The action that caused the event.</param> | |
| 214 /// <param name="changedItems">The items affected by the change.</param> | |
| 215 /// <param name="index">The new index for the changed items.</param> | |
| 216 /// <param name="oldIndex">The old index for the changed items.</param> | |
| 217 public NotifyCollectionChangedEventArgs( | |
| 218 NotifyCollectionChangedAction action, | |
| 219 IList changedItems, | |
| 220 int index, | |
| 221 int oldIndex) | |
| 222 { | |
| 223 _action = action; | |
| 224 | |
| 225 _newItems = changedItems; | |
| 226 _newStartingIndex = index; | |
| 227 _oldItems = changedItems; | |
| 228 _oldStartingIndex = oldIndex; | |
| 229 } | |
| 230 | |
| 231 #endregion | |
| 232 | |
| 233 #region Properties | |
| 234 | |
| 235 private readonly NotifyCollectionChangedAction _action; | |
| 236 /// <summary> | |
| 237 /// The action that caused the event. | |
| 238 /// </summary> | |
| 239 public NotifyCollectionChangedAction Action | |
| 240 { | |
| 241 get { return _action; } | |
| 242 } | |
| 243 | |
| 244 private readonly IList _newItems; | |
| 245 /// <summary> | |
| 246 /// The items affected by the change. | |
| 247 /// </summary> | |
| 248 public IList NewItems | |
| 249 { | |
| 250 get { return _newItems; } | |
| 251 } | |
| 252 | |
| 253 private readonly IList _oldItems; | |
| 254 /// <summary> | |
| 255 /// The old items affected by the change (for Replace events). | |
| 256 /// </summary> | |
| 257 public IList OldItems | |
| 258 { | |
| 259 get { return _oldItems; } | |
| 260 } | |
| 261 | |
| 262 private readonly int _newStartingIndex = -1; | |
| 263 /// <summary> | |
| 264 /// The index where the change occurred. | |
| 265 /// </summary> | |
| 266 public int NewStartingIndex | |
| 267 { | |
| 268 get { return _newStartingIndex; } | |
| 269 } | |
| 270 | |
| 271 private readonly int _oldStartingIndex = -1; | |
| 272 /// <summary> | |
| 273 /// The old index where the change occurred (for Move events). | |
| 274 /// </summary> | |
| 275 public int OldStartingIndex | |
| 276 { | |
| 277 get { return _oldStartingIndex; } | |
| 278 } | |
| 279 | |
| 280 #endregion | |
| 281 } | |
| 282 | |
| 283 /// <summary> | |
| 284 /// The delegate to use for handlers that receive the CollectionChanged event. | |
| 285 /// </summary> | |
| 286 public delegate void NotifyCollectionChangedEventHandler(object sender, NotifyCollectionChangedEventArgs e); | |
| 287 } | |
| 288 | |
| 289 namespace System.Runtime.CompilerServices | |
| 290 { | |
| 291 internal class ExtensionAttribute : Attribute {} | |
| 292 } | |
| 293 | |
| 294 #endif |
