Пример #1
0
        public void TestListExplicitImplementation()
        {
            var list = new List2 <int>();

            Assert.AreEqual(0, list[0]);
            Assert.True(list.Contains(0));
            Assert.AreEqual(1000, list.Count);
            Assert.False(list.IsReadOnly);
            Assert.Null(list.GetEnumerator());
            Assert.AreEqual(2000, list.IndexOf(0));
            Assert.True(list.Remove(0));
            var a = new int[] { 1, 2 };

            list.CopyTo(a, 0);
            Assert.AreEqual(0, a[1]);

            IList <int> list2 = new List2 <int>();

            Assert.AreEqual(0, list2[0]);
            Assert.True(list2.Contains(0));
            Assert.AreEqual(1000, list2.Count);
            Assert.False(list.IsReadOnly);
            Assert.Null(list2.GetEnumerator());
            Assert.AreEqual(2000, list2.IndexOf(0));
            Assert.True(list2.Remove(0));
            var a2 = new int[] { 1, 2 };

            list2.CopyTo(a, 0);
            Assert.AreEqual(2, a2[1]);
        }
Пример #2
0
        private void Text_Changed(object sender, TextChangedEventArgs e)
        {
            var textBox = sender as TextBox;

            // MessageBox.Show("Search "+ textBox.Text);
            if (SaveList2 != null)
            {
                foreach (Softver s in SaveList2)
                {
                    if (!List2.Contains(s))
                    {
                        List2.Add(s);
                    }
                }
            }
            if (textBox.Text != "")

            {
                SaveList2 = new List <Softver>();
                foreach (Softver s in List2)
                {
                    if (s != null)
                    {
                        SaveList2.Add(s);
                    }
                }

                //MessageBox.Show("Savelist: "+ SaveList2.Count);

                List <Softver> filtered = new List <Softver>();
                foreach (Softver s in List2)
                {
                    if (!s.Naziv.Contains(textBox.Text) && !s.Oznaka.Contains(textBox.Text))
                    {
                        filtered.Add(s);
                    }
                }
                if (filtered.Count != 0)
                {
                    foreach (Softver f in filtered)
                    {
                        List2.Remove(f);
                    }
                    //List2.Remove(s => s);
                    // List2 = new ObservableCollection<Softver>(filtered);
                    // MessageBox.Show("jepp: "+filtered.Count);
                }
            }
        }