Exemplo n.º 1
0
        private (string, int) getSinglarStoredType(ArrayPropertyViewModel inv)
        {
            string foundItemType = string.Empty;
            int    total         = 0;

            foreach (StructPropertyViewModel element in inv.Elements)
            {
                DynamicStructDataViewModel structData = (DynamicStructDataViewModel)element.StructData;
                InventoryItem        item             = (InventoryItem)((StructPropertyViewModel)structData.Fields[0]).StructData;
                IntPropertyViewModel numItems         = (IntPropertyViewModel)structData.Fields[1];
                if (item.ItemType != string.Empty && foundItemType != item.ItemType)
                {
                    if (foundItemType == string.Empty)
                    {
                        foundItemType = item.ItemType;
                        total         = numItems.Value;
                    }
                    else
                    {
                        // there is more than one type in this inventory
                        return(string.Empty, 0);
                    }
                }
                else
                {
                    total += numItems.Value;
                }
            }

            return(foundItemType, total);
        }
Exemplo n.º 2
0
        public void GeneralPropertyViewModelTest()
        {
            PropertyViewModel pvm  = new IntPropertyViewModel();
            DelayNode         node = new DelayNode();

            node.Delay = 3;
            PropertyDescriptor pd = TypeDescriptor.GetProperties(node).Find("Delay", true);

            pvm.Initialize(node, pd);
            Assert.Equal("Delay", pvm.DisplayName);
            pvm.Value = 1;
            Assert.Equal(1, pvm.Value);
        }
Exemplo n.º 3
0
		public void GeneralPropertyViewModelTest()
		{
			PropertyViewModel pvm = new IntPropertyViewModel();
			DelayNode node = new DelayNode();
			node.Delay = 3;
			PropertyDescriptor pd = TypeDescriptor.GetProperties(node).Find("Delay", true);
			pvm.Initialize(node, pd);
			Assert.Equal("Delay", pvm.DisplayName);
			pvm.Value = 1;
			Assert.Equal(1, pvm.Value);
		}