Download MASTER THESIS
Transcript
3.3 Collection Visualizer Section 2.5 (Collections) identified the conceptual difference between IList and IEnumerable collections and the need for obtaining collection items lazily. An important question of how to determine the columns for the Collection visualizer’s grid was also resolved. The Collection visualizer, implemented in CollectionVisualizerWindow , follows these decisions. This section covers the data model of the visualizer, the implementation in WPF and explains how not only rows, but also columns of the grid are evaluated lazily for best possible performance. 3.3.1 Lazy loading items when scrolling Following the common approach to collections, any collection which is not an IList is converted to a List prior to being visualized. The implementation uses a WPF ListView (containing a GridView) and exploits the way in which ListView accesses items from its ItemsSource . When the ItemsSource is an IList, the ListView accesses the items which are needed to be rendered using the IList’s indexer. Our implementation supplies a special collection, called VirtualizingCollection , as the ListView.ItemsSource . This collection is a wrapper around some data source (in our case the debuggee collection) and when asked for an item at index i it queries its underlying data source for item i, returns it and caches it. This principle is often referred to as data virtualization. Figure 39 (Class diagram) – Data virtualization using VirtualizingCollection<T> The top half of the class diagram in Figure 39 is a generic data virtualization implementation. The bottom half is specific to debugging. The items returned by the indexer of ListValuesProvider are instances of ObjectValue – a representation of a collection item specific to the Collection visualizer. ObjectValue contains the index of the item in the collection and a map of values of item’s properties. The map of property values in ObjectValue is used to provide indexing by property name, which is used by the data binding of dynamically created ListView columns (based on the 69