Exemplo n.º 1
0
        public async Task RemoveLastItem()
        {
            this.LastItemToRemove.FridgeId = App.ClientId;
            await this.SendItemDeletionAsync(this.LastItemToRemove);

            this.LastItemToRemove = null;
        }
        public void Update_WhenSameItem_ValueIsUpdated()
        {
            var item = new SimpleItem { Value = "A" };

            using (var unitOfWork = Database.CreateUnitOfWork())
            {
                unitOfWork.Insert(item);
                unitOfWork.Commit();
            }

            using (var unitOfWork = Database.CreateUnitOfWork())
            {
                item.Value = "B";

                unitOfWork.Update(item);
                unitOfWork.Commit();
            }

            var propertyHash =
                Database.StructureSchemas.GetSchema<SimpleItem>().IndexAccessors
                .Single(iac => iac.Name.StartsWith("Value")).Name;
            var table = DbHelper.GetTableBySql(
                "select [{0}] from dbo.SimpleItemIndexes where StructureId = '{1}'".Inject(propertyHash, item.Id));
            Assert.AreEqual(1, table.Rows.Count);
            Assert.AreEqual("B", table.AsEnumerable().First()[0]);
        }
Exemplo n.º 3
0
        public void ProcessItem(Item item)
        {
            var priceString = item.Note;
            var matches     = this.regExp.Match(priceString);

            var amount        = this.ParseToDouble(matches.Groups[1].Value);
            var priceCurrency = matches.Groups[2].Value;
            var currency      = item.TypeLine;

            if (amount <= 0)
            {
                return;
            }

            var tempItem = new SimpleItem
            {
                Id            = item.Id,
                PriceAmount   = amount,
                PriceCurrency = priceCurrency,
                TypeLine      = currency
            };

            this.stashIDs[this.currentStashID].Add(item.Id, tempItem);

            //Console.WriteLine($"Selling {currency} for {amount} {priceCurrency}!");
            this.EvaluatePrice(this.TranslateCurrencyToShort(currency), priceCurrency, amount);
        }
        public ActionResult IconAndTitleList()
        {
            /* Populate with: Children of Datasource OR Children of Current */
            IEnumerable <SimpleItem> items = new SimpleItem(DataSourceItemOrCurrentItem).ChildrenInCurrentLanguage;

            return(!items.IsNullOrEmpty() ? View(items) : ShowListIsEmptyPageEditorAlert());
        }
Exemplo n.º 5
0
        protected override List <Item> BuildItems(ref Item defaultItem)
        {
            if (Prefab == null)
            {
                return(new List <Item>());
            }

            var defaultTree = TreeUtils.GetDefaultTree(Prefab, Position);

            if (defaultTree == null)
            {
                return(new List <Item>());
            }

            var trees = TreeUtils.GetAvailableTrees();

            var items = new List <Item> {
                new SimpleItem("#NONE#", null)
            };

            foreach (var tree in trees)
            {
                var item = new SimpleItem(tree.name, tree);
                items.Add(item);

                if (tree == defaultTree)
                {
                    defaultItem = item;
                }
            }

            //Debug.Log($"Built {items.Count} tree items with default {defaultTree} in lane {Position}");

            return(items);
        }
Exemplo n.º 6
0
    private void AssignFaceAccessory(Item.ItemType _itemType, GameObject _character)
    {
        List <Item> itemsList = m_itemsDatabase.GetItems(_itemType);
        int         itemIndex = Random.Range(0, itemsList.Count);
        SimpleItem  item      = (SimpleItem)itemsList[itemIndex];

        _character.GetComponent <Character>().AssignFaceAccessory(item);
    }
        public ActionResult DatasourceList()
        {
            /* make sure the datasource or current has children in the current language and render accordingly */
            IEnumerable <SimpleItem> items   = new SimpleItem(DataSourceItemOrCurrentItem).ChildrenInCurrentLanguage;
            SimpleItemList           results = new SimpleItemList(DataSourceItem["Menu Title"], items);

            return(!items.IsNullOrEmpty() ? View(results) : ShowListIsEmptyPageEditorAlert());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name,Number")] SimpleItem simpleItem)
        {
            if (id != simpleItem.Id)
            {
                return(NotFound());
            }

            return(View(simpleItem));
        }
 private void GenerateSimpleItems()
 {
     for (int i = 0; i < 100; i++)
     {
         var simpleItem = new SimpleItem();
         simpleItem.Id = i;
         _simpleItems.Add(simpleItem);
     }
 }
Exemplo n.º 10
0
        private void listView1_MouseClick(object sender, MouseEventArgs e)
        {
            SimpleItem item = (SimpleItem)listView1.SelectedItems[0];

            if (e.Button == MouseButtons.Right)
            {
                shellMenu.ShowContextMenu(new FileInfo[] { item.TargetFile }, Control.MousePosition);
                LoadDir(Settings.sorter[Settings.NowTabIndex]);
            }
        }
Exemplo n.º 11
0
 private void AssertItem(SimpleItem expected, SimpleItem actual)
 {
     if (expected == null)
     {
         Assert.IsNull(actual);
         return;
     }
     Assert.AreEqual(expected.GetValue(), actual.GetValue());
     AssertItem(expected.GetChild(), actual.GetChild());
 }
Exemplo n.º 12
0
        private void EvaluateRemovedItem(SimpleItem item)
        {
            var value    = this.GetAvgValueForCurrency(item.PriceCurrency) * item.PriceAmount;
            var average  = this.GetAvgValueForCurrency(this.TranslateCurrencyToShort(item.TypeLine));
            var offValue = value > average ? value / average : average / value;

            // if offValue is big -> item was probably removed
            // if offValue is small -> item was sold for this price -> add it with big impact
            // if offValue is medium -> ???
        }
Exemplo n.º 13
0
        public void GetListItemPropertiesTest()
        {
            SimpleItem [] items = new SimpleItem [0];
            PropertyDescriptorCollection properties = ListBindingHelper.GetListItemProperties(items);

            Assert.AreEqual(1, properties.Count, "#A1");
            Assert.AreEqual("Value", properties [0].Name, "#A2");

            List <SimpleItem> items_list = new List <SimpleItem> ();

            properties = ListBindingHelper.GetListItemProperties(items_list);

            Assert.AreEqual(1, properties.Count, "#B1");
            Assert.AreEqual("Value", properties [0].Name, "#B2");

            // Empty arraylist
            ArrayList items_arraylist = new ArrayList();

            properties = ListBindingHelper.GetListItemProperties(items_arraylist);

            Assert.AreEqual(0, properties.Count, "#C1");

            // Non empty arraylist
            items_arraylist.Add(new SimpleItem());
            properties = ListBindingHelper.GetListItemProperties(items_arraylist);

            Assert.AreEqual(1, properties.Count, "#D1");
            Assert.AreEqual("Value", properties [0].Name, "#D2");

            // non list object
            properties = ListBindingHelper.GetListItemProperties(new SimpleItem());

            Assert.AreEqual(1, properties.Count, "#E1");
            Assert.AreEqual("Value", properties [0].Name, "#E2");

            // null value
            properties = ListBindingHelper.GetListItemProperties(null);

            Assert.AreEqual(0, properties.Count, "#F1");

            // ListSource
            properties = ListBindingHelper.GetListItemProperties(new ListSource(true));

            Assert.AreEqual(1, properties.Count, "#G1");
            Assert.AreEqual("Value", properties [0].Name, "#G2");

            // ITypedList
            DataTable table = new DataTable();

            table.Columns.Add("Name", typeof(string));

            properties = ListBindingHelper.GetListItemProperties(table);
            Assert.AreEqual(1, properties.Count, "#H1");
            Assert.AreEqual("Name", properties [0].Name, "#H2");
        }
Exemplo n.º 14
0
        private async Task SendItemAsync(SimpleItem item)
        {
            var url         = "http://happyhappa-uh.azurewebsites.net/api/item/";
            var restManager = new RestManagerBase();
            var result      = await restManager.PutWithJsonPayload(url, item);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                this.LastSavedItem = item;
            }
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Create([Bind("Id,Name,Number")] SimpleItem simpleItem)
        {
            if (ModelState.IsValid)
            {
                await stateSvc.AddItemAsync(simpleItem);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(simpleItem));
        }
Exemplo n.º 16
0
        public async Task AddItemAsync(SimpleItem item)
        {
            var sm = this.StateManager;

            var items = await sm.TryGetStateAsync <List <SimpleItem> >("items");

            var listOfItems = items.HasValue ? items.Value : new List <SimpleItem>();

            listOfItems.Add(item);
            await sm.AddOrUpdateStateAsync("items", listOfItems, (stName, _) => listOfItems);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 窗口列表快捷方式双击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SelectItem(object sender, EventArgs e)
        {
            ListView   listView = (ListView)sender;
            SimpleItem item     = (SimpleItem)listView.SelectedItems[0];

            using (Process p = new Process()) {
                p.StartInfo.FileName = item.TargetFile.FullName;
                p.Start();
                p.Close();
            }
        }
Exemplo n.º 18
0
        private void AssertCycle(IList list, string childName, string parentName, int level
                                 )
        {
            SimpleItem foo = GetItem(list, childName);
            SimpleItem bar = GetItem(list, parentName);

            Assert.IsNotNull(foo);
            Assert.IsNotNull(bar);
            Assert.AreSame(foo, bar.GetChild(level));
            Assert.AreSame(foo.GetParent(), bar.GetParent());
        }
Exemplo n.º 19
0
        public void GetListNameTest()
        {
            List <int> list = new List <int> ();

            int []     arr  = new int [0];
            SimpleItem item = new SimpleItem();

            Assert.AreEqual(typeof(int).Name, ListBindingHelper.GetListName(list, null), "1");
            Assert.AreEqual(typeof(int).Name, ListBindingHelper.GetListName(arr, null), "2");
            Assert.AreEqual(typeof(SimpleItem).Name, ListBindingHelper.GetListName(item, null), "3");
            Assert.AreEqual(String.Empty, ListBindingHelper.GetListName(null, null), "4");
        }
Exemplo n.º 20
0
 /// <summary>
 /// Will check wether a username is saved. If so, the current points
 /// of the user will be downloaded.
 /// </summary>
 private void checkUsername()
 {
     if (!DBManager.Static.DBAccessor.IsEmpty <SimpleItem>())
     {
         SimpleItem si = DBManager.Static.DBAccessor.Select <SimpleItem>()[0];
         if (si.Name.Equals("username"))
         {
             _username = si.Value;
             getPoints();
         }
     }
 }
        public CustomisableItem GetItemType(Item item)
        {
            CustomisableItem c = GetAllItems().First(a => a.Name == item.Name);

            if (c == null)
            {
                c = new SimpleItem();
            }

            c.Clone(item);
            return(c);
        }
        public ActionResult TeamList()
        {
            /* Populate with: Children of Datasource OR Children of Current */
            Item team = SiteConfiguration.GetTeamItem();

            if (team != null && team.Template.Key == "team section")
            {
                IEnumerable <SimpleItem> items = new SimpleItem(DataSourceItemOrCurrentItem).ChildrenInCurrentLanguage;
                return(!items.IsNullOrEmpty() ? View(items) : null);
            }
            return(null);
        }
Exemplo n.º 23
0
        public override void Help(Player p)
        {
            SimpleItem item = (SimpleItem)Economy.GetItem("Snack");

            p.Message("&T/Eat &H- Eats a random snack.");

            if (item.Price == 0)
            {
                return;
            }
            p.Message("&HCosts {0} &3{1} &Heach time", item.Price, Server.Config.Currency);
        }
Exemplo n.º 24
0
 public DBSelectSpecs(SimpleItem model, int max = 0,
                      int limit = 0)
 {
     _model = model;
     if (max != 0)
     {
         _max = max;
     }
     if (limit != 0)
     {
         _limit = limit;
     }
 }
Exemplo n.º 25
0
 private void AssertListWithCycles(IList expectedList, IList actualList)
 {
     Assert.AreEqual(expectedList.Count, actualList.Count);
     for (int i = 0; i < expectedList.Count; ++i)
     {
         SimpleItem expected = (SimpleItem)expectedList[i];
         SimpleItem actual   = (SimpleItem)actualList[i];
         AssertItem(expected, actual);
     }
     AssertCycle(actualList, "foo", "bar", 1);
     AssertCycle(actualList, "foo", "foobar", 1);
     AssertCycle(actualList, "foo", "baz", 2);
 }
        public override Groups GetAdditionalComputerDetails()
        {
            Groups     container = new Groups();
            Group      mainGroup = new Group("API Task Monitor Plugin");
            SimpleItem message   = new SimpleItem("Errors detected in API Task Management");
            SimpleItem date      = new SimpleItem("Current Date:  ", System.DateTime.Now.Date.ToShortDateString());

            mainGroup.Items.Add(date);
            mainGroup.Items.Add(message);
            container.Add(mainGroup);

            return(container);
        }
Exemplo n.º 27
0
        protected override List <Item> BuildItems(ref Item defaultItem)
        {
            if (!(Prefab.m_netAI is TrainTrackBaseAI || Prefab.m_netAI is RoadBaseAI))
            {
                return(new List <Item>());
            }

            var defaultCatenaries = GetDefaultCatenaries();

            if (defaultCatenaries.Count == 0)
            {
                return(new List <Item>());
            }

            var items = new List <Item>()
            {
                new SimpleItem("#NONE#", null)
            };

            PropInfo singleDefaultCatenary   = null;
            var      uniqueDefaultCatenaries = new HashSet <PropInfo>(defaultCatenaries.Values);

            if (uniqueDefaultCatenaries.Count == 1)
            {
                singleDefaultCatenary = uniqueDefaultCatenaries.First();
            }
            else
            {
                defaultItem = new DefaultVariantItem();
                items.Add(defaultItem);
            }

            var catenaryType = GetCatenaryType(uniqueDefaultCatenaries);

            var catenaries = GetAvailableCatenaries(catenaryType);

            foreach (var catenary in catenaries)
            {
                var item = new SimpleItem(catenary.name, catenary);
                items.Add(item);

                if (catenary == singleDefaultCatenary)
                {
                    defaultItem = item;
                }
            }

            //Debug.Log($"Built {items.Count} catenary items with default {singleDefaultCatenary}");

            return(items);
        }
Exemplo n.º 28
0
        private static void RealWorldScenario()
        {
            var rnd = new Random();

            using (var manager = new SimpleItemFirstLevelCacheManager())
            {
                for (int i = 0; i < MaxItemCount; i++)
                {
                    var entity = new SimpleItem()
                    {
                        ContainerName = "TestContainer",
                        FieldName     = "TestField",
                        FieldValue    = "Test"
                    };
                    manager.Add(entity);
                }

                for (int i = 0; i < MaxItemCount; i++)
                {
                    var entity = new SimpleItem()
                    {
                        PkId          = i + 1,
                        ContainerName = "TestContainer" + i,
                        FieldName     = "TestField" + i,
                        FieldValue    = "Test" + i
                    };
                    manager.Update(entity);
                }

                //manager.Refresh(true);


                for (int i = 0; i < MaxItemCount / 10; i++)
                {
                    var t = rnd.Next(MaxItemCount);
                    try
                    {
                        manager.Delete(i);
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch { }
                }

                var result = manager.AsQueryable().Take(MaxItemCount).ToList();
                foreach (var simpleItem in result)
                {
                    Console.WriteLine("PkId: {0}, ContainerName: {1}, FieldName: {2}, FieldValue: {3}", simpleItem.PkId, simpleItem.ContainerName, simpleItem.FieldName, simpleItem.FieldValue);
                }
            }
        }
Exemplo n.º 29
0
        private void ChangeInProviderB()
        {
            SimpleListHolder simpleListHolder = (SimpleListHolder)GetOneInstance(B(), typeof(
                                                                                     SimpleListHolder));
            SimpleItem fooBaby = new SimpleItem(simpleListHolder, "foobaby");

            B().Provider().StoreNew(fooBaby);
            simpleListHolder.Add(fooBaby);
            SimpleItem foo = GetItem(simpleListHolder, "foo");

            foo.SetChild(fooBaby);
            B().Provider().Update(foo);
            B().Provider().Update(simpleListHolder.GetList());
            B().Provider().Update(simpleListHolder);
        }
Exemplo n.º 30
0
 private static void FillDatabase()
 {
     using (var repository = new SimpleItemRepository())
     {
         for (int i = 0; i < 1000; i++)
         {
             var entity = new SimpleItem()
             {
                 ContainerName = "TestContainer",
                 FieldName     = "TestField",
                 FieldValue    = "Test"
             };
             repository.Insert(entity, true);
         }
     }
 }
Exemplo n.º 31
0
            public override bool Equals(object obj)
            {
                if (obj == null)
                {
                    return(false);
                }

                if (obj.GetType() != this.GetType())
                {
                    return(false);
                }

                SimpleItem item = (SimpleItem)obj;

                return(item.foo == foo);
            }
Exemplo n.º 32
0
 void Awake()
 {
     bStarter = battleStarter;
     staticNpcPrefab = npcPrefab;
     PlayerData data = DataScript.Load();
     Debug.Log(data.name);
     name = data.name;
     if(data.name.Equals("uninitialized")){
         items = new List<SimpleItem>();
         playersMonsters = new List<SimpleMonster>();
         SimpleMonster monster = new SimpleMonster();
         monster.name = "Snake";
         monster.level = 10;
         monster.totalExp = 10000;
         monster.moves = new List<SimpleMove>();
         monster.status = "OK";
         monster.type = "snake";
         monster.health = 100;
         monster.id = 1;
         SimpleMove move = new SimpleMove();
         move.name = "Bite";
         move.baseAttack = 10;
         move.accuracy = 95;
         move.id = 1;
         move.type = "snake";
         monster.moves.Add (move);
         playersMonsters.Add(monster);
         SimpleBattleNpc bNpc = new SimpleBattleNpc();
         bNpc.finishBattleText = "You suck!";
         bNpc.moneyGiven = 10;
         bNpc.monsters = new List<SimpleMonster>();
         monster = new SimpleMonster();
         monster.name = "Snake";
         monster.level = 10;
         monster.totalExp = 10000;
         monster.moves = new List<SimpleMove>();
         monster.status = "OK";
         monster.type = "snake";
         monster.health = 100;
         monster.id = 1;
         move = new SimpleMove();
         move.name = "Bite";
         move.baseAttack = 10;
         move.accuracy = 95;
         move.id = 1;
         move.type = "snake";
         monster.moves.Add (move);
         bNpc.monsters.Add(monster);
         bNpc.name = "Ben Call";
         bNpc.id = 1;
         bNpc.xPos = 3f;
         bNpc.yPos = 3f;
         simpleBattleNpcs = new List<SimpleBattleNpc>();
         simpleBattleNpcs.Add(bNpc);
         SimpleItem item = new SimpleItem();
         item.buyCost = 100;
         item.name = "Potion";
         item.sellCost = 50;
         items.Add(item);
         SimpleNPC npc = new SimpleNPC();
         npc.name = "Ben Smith";
         npc.conversationText = "Felgergarb";
         npc.xPos = 1.0f;
         npc.yPos = 10.0f;
         simpleNPCs = new List<SimpleNPC>();
         simpleNPCs.Add(npc);
         money = 100;
         playerStartPosX = 0f;
         playerStartPosY = 0f;
         data.name = "Joseph";
         data.items = items;
         data.simpleNpcs = simpleNPCs;
         DataScript.Save (data);
     }
     Debug.Log (data.money);
     foreach(SimpleItem item in data.items){
         Debug.Log (item.name);
     }
     foreach(SimpleNPC npc in data.simpleNpcs){
         Debug.Log (npc.name);
     }
     data.name = "uninitialized";
     DataScript.Save (data);
 }
Exemplo n.º 33
0
		public void GetListNameTest ()
		{
			List<int> list = new List<int> ();
			int [] arr = new int [0];
			SimpleItem item = new SimpleItem ();

			Assert.AreEqual (typeof (int).Name, ListBindingHelper.GetListName (list, null), "1");
			Assert.AreEqual (typeof (int).Name, ListBindingHelper.GetListName (arr, null), "2");
			Assert.AreEqual (typeof (SimpleItem).Name, ListBindingHelper.GetListName (item, null), "3");
			Assert.AreEqual (String.Empty, ListBindingHelper.GetListName (null, null), "4");
		}
Exemplo n.º 34
0
		public void GetListItemPropertiesTest ()
		{
			SimpleItem [] items = new SimpleItem [0];
			PropertyDescriptorCollection properties = ListBindingHelper.GetListItemProperties (items);

			Assert.AreEqual (1, properties.Count, "#A1");
			Assert.AreEqual ("Value", properties [0].Name, "#A2");

			List<SimpleItem> items_list = new List<SimpleItem> ();
			properties = ListBindingHelper.GetListItemProperties (items_list);

			Assert.AreEqual (1, properties.Count, "#B1");
			Assert.AreEqual ("Value", properties [0].Name, "#B2");

			// Empty arraylist
			ArrayList items_arraylist = new ArrayList ();
			properties = ListBindingHelper.GetListItemProperties (items_arraylist);

			Assert.AreEqual (0, properties.Count, "#C1");

			// Non empty arraylist
			items_arraylist.Add (new SimpleItem ());
			properties = ListBindingHelper.GetListItemProperties (items_arraylist);

			Assert.AreEqual (1, properties.Count, "#D1");
			Assert.AreEqual ("Value", properties [0].Name, "#D2");

			// non list object
			properties = ListBindingHelper.GetListItemProperties (new SimpleItem ());

			Assert.AreEqual (1, properties.Count, "#E1");
			Assert.AreEqual ("Value", properties [0].Name, "#E2");

			// null value
			properties = ListBindingHelper.GetListItemProperties (null);

			Assert.AreEqual (0, properties.Count, "#F1");

			// ListSource
			properties = ListBindingHelper.GetListItemProperties (new ListSource (true));

			Assert.AreEqual (1, properties.Count, "#G1");
			Assert.AreEqual ("Value", properties [0].Name, "#G2");

			// ITypedList
			DataTable table = new DataTable ();
			table.Columns.Add ("Name", typeof (string));

			properties = ListBindingHelper.GetListItemProperties (table);
			Assert.AreEqual (1, properties.Count, "#H1");
			Assert.AreEqual ("Name", properties [0].Name, "#H2");
		}