Tanoda
ListCacheEntry.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3
5{
7 {
8 private Type _type;
9 private readonly IList _list;
10 private readonly int _index;
11
12 public ListCacheEntry(IList container, int index) : base(ReadonlyListCacheEntry.GetListItemName(index))
13 {
14 _index = index;
15 _list = container;
16 }
17
18 public override object GetValueToCache()
19 {
20 return _list.Count > _index ? _list[_index] : "ERROR: The list was changed while browsing!";
21 }
22
23 protected override bool OnSetValue(object newValue)
24 {
25 if (CanSetValue())
26 {
27 _list[_index] = newValue;
28 _type = null;
29 return true;
30 }
31
32 return false;
33 }
34
35 public override Type Type()
36 {
37 return _type ?? (_type = GetValue().GetType());
38 }
39
40 public override bool CanSetValue()
41 {
42 return !_list.IsReadOnly;
43 }
44 }
45}
virtual object GetValue()
override bool CanSetValue()
override Type Type()
ListCacheEntry(IList container, int index)
override bool OnSetValue(object newValue)
override object GetValueToCache()