public void GetRange() { var list = new ObservableList <int>(sampleList); var newList = list.GetRange(1, 2); Assert.AreEqual(2, newList.Count); Assert.AreEqual(2, newList[0]); Assert.AreEqual(3, newList[1]); }
public void GetRangeWithIndexes() { var list = new ObservableList <int>(new List <int> { 1, 2, 3, 4, 5 }); var newList = list.GetRange(1, 2); Assert.AreEqual(2, newList.Count); Assert.AreEqual(2, newList[0]); Assert.AreEqual(3, newList[1]); }
private void OnContainerCreated(int containerId, ObservableList <ItemInstance> items) { String containerName; if (containerId == GameState.Instance.InventoryContainerId) { Toolbar.SetItems(new ObservableList <ItemInstance>(items.GetRange(0, NumItemsInToolbar))); Toolbar.ContainerId = containerId; containerName = "Inventory"; } else if (containerId == GameState.Instance.EquipmentContainerId) { containerName = "Equipment"; } else { containerName = "Container " + containerId; } ContainerView containerView = ContainerViews.Find(cv => cv.ContainerId == containerId); if (!containerView) { containerView = ContainerGroup.CreateView <ContainerView>(); containerView.Alignment.Value = ElementAlignment.Right; containerView.ContainerName = containerName; containerView.SetItems(items); containerView.ContainerId = containerId; containerView.InitializeViews(); ContainerViews.Add(containerView); } else { containerView.SetItems(items); } if (ContainerViews.Count() > _maxContainerViewsAllowed) { // index 0 is the inventory ContainerViews[1].Destroy(); ContainerViews.RemoveAt(1); } }