title: Custom collection using cache class
body: <p>I am trying to improve performance by limiting my objects in memory by using a cache.</p>
  
  <p>This creates problem with my ObservableCollection. Well, i think the code speaks for itself. I have "transformed" my ObservableCollection-derivative to this:</p>
  
  <pre><code>public class TrackCollection : INotifyPropertyChanged, IEnumerable {
      private readonly List&lt;Guid&gt; _guids = new List&lt;Guid&gt;();
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      private void NotifyPropertyChanged(String info) {
          if (PropertyChanged != null) {
              PropertyChanged(this, new PropertyChangedEventArgs(info));
          }
      }
  
      public void Add(Track track) {
          _guids.Add(track.Id);
      }
  
      public void Add(Guid trackId) {
          _guids.Add(trackId);
      }
  
      public IEnumerator GetEnumerator() {
          var tracks = new List&lt;Track&gt;(_guids.Count);
          foreach(Guid id in _guids)
              tracks.Add(MediaCache.Instance.GetTrack(id));
  
          return tracks.GetEnumerator();
      }
  }
  </code></pre>
  
  <p>When i call the Add-methods i would like to call my <code>NotifyPropertyChanged</code> on the class it self.</p>
  
  <p>I have a feeling that this is the wrong approach to this kind of problem, it feels like a workaround.</p>
  
  <p>Anyways, is this the correct solution, and if so, how should i proceed?</p>
  
  <hr>
  
  <p>The cache method looks like this:</p>
  
  <pre><code>    private readonly List&lt;Track&gt; _tracks = new List&lt;Track&gt;();
      public Track GetTrack(Guid id) {
          foreach (var track in _tracks.Where(track =&gt; track.Id == id))
              return track;
  
          _tracks.Add(Database.Database.Instance.GetTrack(id));
          return _tracks[_tracks.Count - 1];
      }
  </code></pre>