protected virtual void PopulateEnumerableItems(IEnumerable enumerable, Type exposedType) { if (_enumerableItems == null) { _enumerableItems = new Dictionary <object, WoopsaObjectAdapter>(); } if (exposedType != null) { WoopsaTypeUtils.GetGenericEnumerableItemType(exposedType, out _itemExposedType); } _iNotifyCollectionChanged = enumerable as INotifyCollectionChanged; if (_iNotifyCollectionChanged != null) { _iNotifyCollectionChanged.CollectionChanged += EnumerableCollectionChanged; } int index = 0; foreach (object item in enumerable) { if (item != null) { WoopsaObjectAdapter adapter = AddEnumerableItem(item); adapter.EnumerableItemIndex = index; index++; } } }
private WoopsaObjectAdapter AddEnumerableItem(object item) { WoopsaObjectAdapter itemAdapter = CreateItemWoopsaAdapter(EnumerableItemName(item, _nextEnumerableItemId), () => item, _itemExposedType); itemAdapter.EnumerableItemId = _nextEnumerableItemId; _enumerableItems[item] = itemAdapter; _nextEnumerableItemId++; return(itemAdapter); }