Inheritance: DictionaryBase
Example #1
0
 public void testAs3()
 {
     var x = new MyCollection();
     AssertNotNull(AsIEnumerable(x));
     AssertNotNull(AsICollection(x));
     AssertNull(AsIList(x));
 }
 public static void Main() {
 int errors = 0;
 int testcases = 0;
 try {
 testcases++;
 MyCollection MyColl = new MyCollection();
 MyColl.UseOnInsertComplete((object)3, (object)5);
 } catch(Exception e) {
 errors++;
 }
 try {
 testcases++;
 MyCollection MyColl = new MyCollection();
 MyColl.UseOnInsertComplete((object)3, (object)(-18));
 } catch(Exception e) {
 errors++;
 }
 try {
 testcases++;
 MyCollection MyColl = new MyCollection();
 MyColl.UseOnInsertComplete((object)(-2), (object)(-12));
 } catch(Exception e) {
 errors++;
 }
 Environment.ExitCode = errors;
 }
Example #3
0
 public void testIs3()
 {
     var x = new MyCollection();
     AssertTrue(IsIEnumerable(x));
     AssertTrue(IsICollection(x));
     AssertFalse(IsIList(x));
 }
 private void button1_Click(object sender, EventArgs e)
 {
     MyCollection mc = new MyCollection("Ani");
     // foreach (string s in mc) //cannot be done as it doesnt know where to search for loop
     foreach (string s in mc)
         MessageBox.Show(s);
 }
 public static void Main() {
 int errors = 0;
 int testcases = 0;
 Environment.ExitCode = 100;
 MyCollection MyColl = new MyCollection();
 try {
 testcases++;
 MyColl.UseOnValidate((object)0, (object)5);
 } catch(Exception e) {
 errors++;
 }
 try {
 testcases++;
 MyColl = new MyCollection();
 MyColl.UseOnValidate((object)5, (object)(-2));
 }  catch(Exception e) {
 errors++;
 }
 try {
 testcases++;
 MyColl = new MyCollection();
 MyColl.UseOnValidate((object)0, (object)5);
 } catch(Exception e) {
 errors++;
 }
 try {
 testcases++;
 MyColl = new MyCollection();
 MyColl.UseOnValidate((object)(-1), (object)5);
 Environment.ExitCode = errors;
 } catch(Exception e) {
 errors++;
 }
 }
 public static void Main() {
 int errors = 0;
 int testcases = 0;
 testcases++;
 MyCollection MyColl = new MyCollection();
 object obj = (object)8 ;
 MyColl.UseOnSetComplete(0, (object)5, obj);
 if(! obj.Equals((object)8)) {
 errors++;
 }
 testcases++;
 MyColl = new MyCollection();
 obj = (object)8 ;
 MyColl.UseOnSetComplete(5, (object)(-2), obj);
 if(! obj.Equals((object)8)) {
 errors++;
 }
 testcases++;
 MyColl = new MyCollection();
 obj = (object)(-19) ;
 MyColl.UseOnSetComplete(0, (object)5, obj);
 if(! obj.Equals((object)(-19))) {
 errors++;
 }
 testcases++;
 MyColl = new MyCollection();
 obj = (object)8 ;
 MyColl.UseOnSetComplete(-1, (object)5, obj);
 if(! obj.Equals((object)8)) {
 errors++;
 }
 Environment.ExitCode = errors;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack&&!GridWeb1.IsPostBack)
      {
        // Creates the collection.
        MyCollection list = new MyCollection();
        System.Random rand = new System.Random();
        for (int i = 0; i < 5; i++)
        {
          //Create custom record object and set properties
          MyCustomRecord rec = new MyCustomRecord();
          rec.DateField1 = DateTime.Now;
          rec.DoubleField1 = rand.NextDouble();
          rec.IntField1 = rand.Next();
          rec.StringField1 = "ABC_" + i;
          ((IList)list).Add(rec);
        }

        //Create web worksheet object
        WebWorksheet sheet = GridWeb1.WebWorksheets[0];

        // Uses the collection as datasource.
        sheet.DataSource = list;

        // Creates bind columns.
        sheet.CreateAutoGenratedColumns();

        // Sets the DateFiled1's validation to DateTime.
        sheet.BindColumns["DateField1"].Validation.ValidationType = ValidationType.DateTime;

        // Binding.
        sheet.DataBind();
      }
    }
Example #8
0
        static void Main(string[] args)
        {
            using (new Watcher("Adding to my collection"))
            {
                MyCollection<int> test = new MyCollection<int>();
                test.Add(3);
                test.Add(4);
                test.Add(5);
                test.Add(363);
                test.Add(8);
                test.Add(45);
            }
            using (new Watcher("Adding to List<int>"))
            {
                List<int> test = new List<int>();
                test.Add(3);
                test.Add(4);
                test.Add(5);
                test.Add(363);
                test.Add(8);
                test.Add(45);
            }
            using (new Watcher("Adding to SortedList<int,int>"))
            {
                SortedList<int,int> test = new SortedList<int, int>();
                test.Add(3,3);
                test.Add(4,4);
                test.Add(5,5);
                test.Add(363,363);
                test.Add(8,8);
                test.Add(45,45);
            }

            Console.ReadLine();
        }
        protected override void Given()
        {
            id = new CollectionIdentity("1");
            usId = new UserStoryIdentity("3");

            collectionState = new CollectionState(new List<IEvent>(){new CollectionCreated("1","To Do", 1), new UserStoryAdded("2")});
            collection = new MyCollection(collectionState);
        }
 public static void Main() {
 int errors = 0;
 int testcases = 0;
 testcases++;
 MyCollection MyColl = new MyCollection();
 MyColl.UseOnClearComplete();
 Environment.ExitCode = errors;
 }
 public static void Main() {
 int errors = 0;
 int testcases = 0;
 testcases++;
 MyCollection MyColl = new MyCollection();
 if(! MyColl.UseComparer())
   errors++;
 Environment.ExitCode = errors;
 }
 private static MyCollection CreateCollection(int count)
 {
     var collBase = new MyCollection();
     for (int i = 0; i < 100; i++)
     {
         collBase.Add(CreateValue(i));
     }
     return collBase;
 }
Example #13
0
 public static void Main(string[] args)
 {
     MyCollection col = new MyCollection();
     Console.WriteLine("Values in the collection are:");
     foreach (int i in col)
     {
         Console.WriteLine(i);
     }
     Console.ReadLine();
 }
Example #14
0
        public static void Ctor_Empty()
        {
            var collBase = new MyCollection();
            var arrList = new ArrayList();

            Assert.Equal(0, collBase.Capacity);
            Assert.Equal(arrList.Capacity, collBase.Capacity);

            Assert.Equal(0, collBase.InnerListCapacity);
        }
 public static void Main() {
 int errors = 0;
 int testcases = 0;
 testcases++;
 ArrayList arrList = new ArrayList();
 MyCollection MyColl = new MyCollection();
 if(! MyColl.UseInnerList(arrList))
   errors++;
 Environment.ExitCode = errors;
 }
        public static void TestCtor_Capacity(int capacity)
        {
            var collBase = new MyCollection(capacity);
            var arrList = new ArrayList(capacity);

            Assert.Equal(capacity, collBase.Capacity);
            Assert.Equal(arrList.Capacity, collBase.Capacity);

            Assert.Equal(capacity, collBase.InnerListCapacity);
        }
Example #17
0
        static void Main(string[] args)
        {
            MyCollection myC = new MyCollection();

            foreach (int val in myC)
            {
                Console.WriteLine(val);
            }

            Console.ReadLine();
        }
Example #18
0
        static void Main(string[] args)
        {
            MyCollection<int> intCollection = new MyCollection<int>(2, 6);
            intCollection.Add(3);
            for(int i=0;i<intCollection.Count();i++)
                Console.WriteLine(intCollection[i]);
            intCollection.Sort();
            Console.WriteLine("После сортировки:");
            for (int i = 0; i < intCollection.Count(); i++)
                Console.WriteLine(intCollection[i]);
            int newInt = intCollection.CreateEntity();
            Console.WriteLine("создали число "+newInt);

            //коллекция котов
            MyCollection<Cat> catCollection = new MyCollection<Cat>();
            catCollection.Add(new Cat { Name = "Мурка", Weight = 8 });
            catCollection.Add(new Cat { Name = "Мурзик", Weight = 15 });
            catCollection.Add(new Cat { Name = "Барсик", Weight = 10 });
            for (int i = 0; i < catCollection.Count(); i++)
                Console.WriteLine(catCollection[i]);

            catCollection.Sort();
            Console.WriteLine("После сортировки:");
            for (int i = 0; i < catCollection.Count(); i++)
                Console.WriteLine(catCollection[i]);

            foreach (Cat cat in catCollection)
                Console.WriteLine(cat);

            Cat newCat = catCollection.CreateEntity();
            Console.WriteLine("Создали кота "+newCat);

            DateTime time1 = DateTime.Now;
            ArrayList arrList = new ArrayList();
            for (int i = 0; i < 1000000;i++ )
            {
                arrList.Add(i);//упаковка
                int x =(int) arrList[i];//распаковка
            }
            Console.WriteLine((DateTime.Now-time1).TotalSeconds);
            arrList.Add("Вася");

            DateTime time2 = DateTime.Now;
            List<int> list = new List<int>();
            for (int i = 0; i < 1000000; i++)
            {
                list.Add(i);
                int x = list[i];
            }
            //list.Add("Вася");
            Console.WriteLine((DateTime.Now - time2).TotalSeconds);
                Console.ReadKey();
        }
Example #19
0
        public void WorkCollectionInheritedClasses()
        {
            //throw new NotImplementedException();
            Student student1 = new Student("Имя", "Фамилия", 11, new DateTime(1967, 1, 1), 1);
            Student student2 = new Student("Имя", "Фамилия", 22, new DateTime(1967, 1, 1), 2);
            Student student3 = new Student("Имя", "Фамилия", 33, new DateTime(1967, 1, 1), 3);
            Student student4 = new Student("Имя", "Фамилия", 44, new DateTime(1967, 1, 1), 4);

            MyDictionary groupForDictionary = new MyDictionary();
            groupForDictionary.Add(student1);
            groupForDictionary.Add(student2);
            groupForDictionary.Add(student3);
            groupForDictionary.Add(student4);

            Tuple<string, string, int, DateTime> workKey = Tuple.Create<string, string, int, DateTime>("Имя", "Фамилия", 22, new DateTime(1967, 1, 1));
            if (!groupForDictionary.Contains(workKey))
            {
                Console.WriteLine("Нет такого студента");
            }

            MyCollection<Student> groupForCollection = new MyCollection<Student>();
            groupForCollection.Add(student1);
            groupForCollection.Add(student3);

            Console.WriteLine("Студент 1,3");
            foreach (Student workStudent in groupForCollection)
            {
                Console.WriteLine("{0} {1} : {2}, {3}, {4} ", workStudent.firstName,
                                                              workStudent.secondName,
                                                              workStudent.birthDate,
                                                              workStudent.rating,
                                                              workStudent.personalCode);
            }

            groupForCollection.Insert(1, student2);
            groupForCollection.Remove(student1);
            groupForCollection.Add(student4);

            Console.WriteLine("+ Студент2, -Студент1,+ Студент4");
            foreach (Student workStudent in groupForCollection)
            {
                Console.WriteLine("{0} {1} : {2}, {3}, {4} ", workStudent.firstName,
                                                                  workStudent.secondName,
                                                                  workStudent.birthDate,
                                                                  workStudent.rating,
                                                                  workStudent.personalCode);
            }

            Console.ReadKey();
        }
 public static void TestAdd()
 {
     MyCollection collBase = new MyCollection();
     for (int i = 0; i < 100; i++)
     {
         Foo value = CreateValue(i);
         collBase.Add(value);
         Assert.True(collBase.Contains(value));
     }
     Assert.Equal(100, collBase.Count);
     for (int i = 0; i < collBase.Count; i++)
     {
         Foo value = CreateValue(i);
         Assert.Equal(value, collBase[i]);               
     }
 }
Example #21
0
 public Form1()
 {
     InitializeComponent();
     plk = "";
     toolStripStatusLabel5.Text = "Колличество фигур:";
     toolStripStatusLabel6.Text = "0";
     bmp1 = new Bitmap(panel2.Width, panel2.Height);
     bmp2 = new Bitmap(panel4.Width, panel4.Height);
     bmp3 = new Bitmap(panel3.Width, panel3.Height);
     g1 = Graphics.FromImage(bmp1);
     g2 = Graphics.FromImage(bmp2);
     g3 = Graphics.FromImage(bmp3);
     gg1 = panel2.CreateGraphics();
     gg2 = panel4.CreateGraphics();
     gg3 = panel3.CreateGraphics();
     Array obj = Enum.GetValues(typeof(DashStyle));
     for (int i = 0; i < obj.Length; i++)
         toolStripComboBox2.Items.Add(obj.GetValue(i).ToString());
     toolStripComboBox2.SelectedIndex = 0;
     obj = Enum.GetValues(typeof(HatchStyle));
     for (int i = 0; i < obj.Length; i++)
         toolStripComboBox1.Items.Add(obj.GetValue(i).ToString());
     toolStripComboBox1.SelectedItem = HatchStyle.Percent10.ToString();
     for (int i = 1; i< 25; i++)
         toolStripComboBox3.Items.Add(i);
     toolStripComboBox3.SelectedIndex = 2;
     figures = new MyCollection();
     buffer = new ArrayList();
     byte k = Color.Transparent.A;
     k = Color.White.A;
     drawcolor(toolStripButton12, Color.Green);
     drawcolor(toolStripButton13, Color.Black);
     drawcolor(toolStripButton14, Color.Gray);
     drawcolor(toolStripButton15, Color.White);
     flag = false;
     pen = false;
     x1 = 0; y1 = 0; x2 = 0; y2 = 0;
     toolStripStatusLabel4.Text="100%";
     toolStripButton3.Enabled = false;
     toolStripButton2.Enabled = false;
 }
Example #22
0
        static void Main(string[] args)
        {
            //1
            task1 objTask1 = new task1();
            Stopwatch stopWatch = new Stopwatch();

            Start(stopWatch);
            objTask1.AddToDictionary();
            Finish(stopWatch);
            Start(stopWatch);
            Console.WriteLine(objTask1.SearchStringInDictinory("500"));
            Finish(stopWatch);

            Start(stopWatch);
            objTask1.AddToList();
            Finish(stopWatch);
            Start(stopWatch);
            Console.WriteLine(objTask1.SearchStringInList("Two households, both alike in dignity,"));
            Finish(stopWatch);

            //2
            MyCollection<int> myCollection = new MyCollection<int>();
            myCollection.AddElementInCollection(23);
            myCollection.AddElementInCollection(7);
            myCollection.AddElementInCollection(3);
            IEnumerator result1 = myCollection.ComparisonObjectWithElementsCollection(23);
            IEnumerator result2 = myCollection.ComparisonObjectWithElementsCollection("23");

            //3
            MyCollection2 myCollect = new MyCollection2();
            myCollect.Add(2);
            myCollect.Add(5);
            myCollect.Add(-10);
            myCollect.Add(1);

            foreach (int i in myCollect)
            {
                System.Console.Write(i + " ");
            }
        }
Example #23
0
            /// <summary>
            /// Moves the appraisers.
            /// </summary>
            /// <param name="databasePath">The database path.</param>
            /// <param name="errOut">The error out.</param>
            /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
            /// <exception cref="System.Exception"></exception>
            /// <exception cref="System.Exception"></exception>
            internal static bool MoveAppraisers(string databasePath, out string errOut)
            {
                errOut = "";
                bool   bAns = false;
                string sql  = "";

                try
                {
                    List <GunCollectionList> lst = MyCollection.GetList(databasePath, out errOut);
                    if (errOut.Length > 0)
                    {
                        throw new Exception(errOut);
                    }
                    BSOtherObjects obj = new BSOtherObjects();
                    foreach (GunCollectionList l in lst)
                    {
                        string name = obj.FC(l.AppriasedBy);
                        if (name?.Length == 0 || name == null)
                        {
                            name = "  ";
                        }
                        if (!ValueDoesExist(databasePath, "Appriaser_Contact_Details", "aName", name, out errOut))
                        {
                            if (!PeopleAndPlaces.Appraisers.Add(databasePath, name, out errOut))
                            {
                                throw new Exception(errOut);
                            }
                        }
                    }
                    bAns = true;
                }
                catch (Exception e)
                {
                    errOut = $"{ErrorMessage("MoveAppraisers", e)}.  {Environment.NewLine} {Environment.NewLine}SQL - {sql}";
                }
                return(bAns);
            }
    public static void Main()
    {
        int errors    = 0;
        int testcases = 0;

        Environment.ExitCode = 100;
        MyCollection MyColl = new MyCollection();

        try {
            testcases++;
            MyColl.UseOnValidate((object)0, (object)5);
        } catch (Exception e) {
            errors++;
        }
        try {
            testcases++;
            MyColl = new MyCollection();
            MyColl.UseOnValidate((object)5, (object)(-2));
        }  catch (Exception e) {
            errors++;
        }
        try {
            testcases++;
            MyColl = new MyCollection();
            MyColl.UseOnValidate((object)0, (object)5);
        } catch (Exception e) {
            errors++;
        }
        try {
            testcases++;
            MyColl = new MyCollection();
            MyColl.UseOnValidate((object)(-1), (object)5);
            Environment.ExitCode = errors;
        } catch (Exception e) {
            errors++;
        }
    }
Example #25
0
        /// <summary>
        /// Ges the current barrel detailst list.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns>List&lt;BarrelSystems&gt;.</returns>
        /// <exception cref="Exception"></exception>
        public static List <BarrelSystems> GetCurrentBarrelDetailstList(string databasePath, long id, out string errOut)
        {
            List <BarrelSystems> lst = new List <BarrelSystems>();

            errOut = @"";
            try
            {
                List <GunCollectionList> gunList = MyCollection.GetList(databasePath, id, out errOut);
                if (errOut?.Length > 0)
                {
                    throw new Exception(errOut);
                }

                foreach (GunCollectionList d in gunList)
                {
                    lst.Add(new BarrelSystems()
                    {
                        Id             = d.Id,
                        FullName       = d.FullName,
                        BarrelLength   = d.BarrelLength,
                        Finish         = d.Finish,
                        Height         = d.Height,
                        Action         = d.Action,
                        FeedSystem     = d.FeedSystem,
                        Sights         = d.Sights,
                        PetLoads       = d.PetLoads,
                        PurchasedFrom  = d.PurchaseFrom,
                        PurchasedPrice = d.PurchasePrice,
                    });
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("GetAll", e);
            }
            return(lst);
        }
Example #26
0
    static void Main1()
    {
        int[] nos = new int[5];
        int[,] mat    = new int[4, 5];
        int[, ,] test = new int[5, 8, 9];

        TestArrayRank(nos);

        string str = "Hello";

        foreach (var t in str)
        {
            Console.WriteLine(t);
        }

        foreach (var t in mat)
        {
            Console.WriteLine(t);
        }

        for (int i = mat.GetLowerBound(0); i <= mat.GetUpperBound(0); i++)
        {
            for (int j = 0; j <= mat.GetUpperBound(1); j++)
            {
                Console.Write("  " + mat[i, j]);
            }
            Console.WriteLine();
        }

        MyCollection c = new MyCollection();

        foreach (var k in c)
        {
            Console.WriteLine(k);
        }
    }
        public override void Draw()
        {
            Tools.QDrawer.Flush();
            Camera Cam = MyLevel.MainCamera;

            Cam.SetVertexCamera();

#if DEBUG && INCLUDE_EDITOR
            if (Tools.background_viewer != null)
            {
                Tools.background_viewer.PreDraw();
                Tools.QDrawer.Flush();
            }
#endif

            if (MyLevel.IndependentDeltaT > 0)
            {
                MyCollection.PhsxStep();
            }

            MyCollection.Draw();

            Tools.QDrawer.Flush();
        }
Example #28
0
        public static void TestCopyTo()
        {
            MyCollection collBase = CreateCollection(100);

            // Basic
            var fooArr = new Foo[100];

            collBase.CopyTo(fooArr, 0);

            Assert.Equal(collBase.Count, fooArr.Length);
            for (int i = 0; i < fooArr.Length; i++)
            {
                Assert.Equal(collBase[i], fooArr.GetValue(i));
            }

            // With index
            fooArr = new Foo[collBase.Count * 2];
            collBase.CopyTo(fooArr, collBase.Count);

            for (int i = collBase.Count; i < fooArr.Length; i++)
            {
                Assert.Equal(collBase[i - collBase.Count], fooArr.GetValue(i));
            }
        }
Example #29
0
        public void OnBtnClick()
        {
            if (String.IsNullOrWhiteSpace(InputString))
            {
                InputString = null;
                return;
            }
            if (Num < 1)
            {
                Num = 1;
                return;
            }
            Model NewModel = new Model
            {
                SomeString = InputString,
                Number     = Num,
                IsDone     = false,
                ItemColour = SelectedCategories.MyColor
            };

            MyCollection.Add(NewModel);
            InputString = null;
            Num         = 1;
        }
Example #30
0
    public bool DefaultCapacity()
    {
        bool retValue = true;
        MyCollection cb = new MyCollection();
        ArrayList al = new ArrayList();

        if (cb.Capacity != al.Capacity)
        {
            Console.WriteLine("ERROR!!! CollectionBase.Capacity={0} expected={1}", cb.Capacity, al.Capacity);
            retValue = false;
        }

        if (cb.InnerListCapacity != al.Capacity)
        {
            Console.WriteLine("ERROR!!! CollectionBase.InnerList.Capacity={0} expected={1}", cb.InnerListCapacity, al.Capacity);
            retValue = false;
        }

        if (!retValue)
        {
            Console.WriteLine("Err_001!!! Verifying Capacity with default constructor FAILED");
        }
        return retValue;
    }
Example #31
0
		public void CollectionChangedWithResetShouldShowItems()
		{
			var count = 10;
			ManualForm($"GridView should show {count} items", form =>
			{
				var collection = new MyCollection();
				var filterCollection = new FilterCollection<DataItem>(collection);
				var myGridView = new GridView
				{
					Size = new Size(200, 260),
					DataStore = filterCollection,
					Columns = {
						new GridColumn {
							DataCell = new TextBoxCell { Binding = Eto.Forms.Binding.Property((DataItem m) => m.Id.ToString()) }
						}
					}
				};
				collection.Clear();
				collection.AddRange(Enumerable.Range(1, count).Select(r => new DataItem(r)));

				return myGridView;
			});

		}
Example #32
0
        public void CustomCollection()
        {
            var simple = new Simple {
                Hello = "neo"
            };
            var collection = new MyCollection
            {
                simple
            };

            poco.MyCollection = collection;

            A.CallTo(() => pocoFactory.FromEmbeddedEntity(typeof(Simple), A <Entity> ._)).Returns(simple);

            var prop  = poco.GetType().GetProperty("MyCollection");
            var value = EntityValueFactory.FromPropertyInfo(poco, prop, entityFactory, new List <string>());

            var actual = PocoValueFactory.FromEntityValue(prop, value, pocoFactory);

            var typed = Assert.IsType <MyCollection>(actual);

            Assert.Equal(1, typed.Count);
            Assert.Equal("neo", typed[0].Hello);
        }
Example #33
0
    public bool DefaultCapacity()
    {
        bool         retValue = true;
        MyCollection cb       = new MyCollection();
        ArrayList    al       = new ArrayList();

        if (cb.Capacity != al.Capacity)
        {
            Console.WriteLine("ERROR!!! CollectionBase.Capacity={0} expected={1}", cb.Capacity, al.Capacity);
            retValue = false;
        }

        if (cb.InnerListCapacity != al.Capacity)
        {
            Console.WriteLine("ERROR!!! CollectionBase.InnerList.Capacity={0} expected={1}", cb.InnerListCapacity, al.Capacity);
            retValue = false;
        }

        if (!retValue)
        {
            Console.WriteLine("Err_001!!! Verifying Capacity with default constructor FAILED");
        }
        return(retValue);
    }
 public static void TestInsert()
 {
     var collBase = new MyCollection();
     for (int i = 0; i < 100; i++)
     {
         Foo value = CreateValue(i);
         collBase.Insert(i, value);
         Assert.True(collBase.Contains(value));
     }
     Assert.Equal(100, collBase.Count);
     for (int i = 0; i < collBase.Count; i++)
     {
         var expected = CreateValue(i);
         Assert.Equal(expected, collBase[i]);
     }
 }
Example #35
0
        public void WorkCollectionInheritedClasses()
        {
            Student firstStudent = new Student("Alina", "Kylish", 123456789, new DateTime(1988, 4, 3));
            Student secondStudent = new Student("Elena", "Kylish", 987654321, new DateTime(1987, 8, 15));
            Student thirdStudent = new Student("Oleg", "Ivanov", 975312468, new DateTime(1992, 11, 20));
            MyDictionary students = new MyDictionary();
            Tuple<string, string, int> key = new Tuple<string,string,int>("Alina", "Kylish", 123456789);
            students.Add(firstStudent);
            if (!students.Contains(key))
            {
                Console.WriteLine("This key is not found");
            }
            else
            {
                Console.WriteLine("This key is found");
            }

            MyCollection students1 = new MyCollection();
            students1.Add(firstStudent);
            students1.Add(secondStudent);
            students1.Insert(0, thirdStudent);
            students1.Add(firstStudent);
            students1.Remove(firstStudent);
            students1.Clear();
            Console.ReadKey();
        }
Example #36
0
 public WrapperClass(MyCollection collection)
 {
     Items   = collection;
     MyField = collection.MyField;
 }
Example #37
0
        public MyCollection <Song> getSearchResults(Dictionary <string, ISearchParameter> searchParams, MyCollection <Song> collection)
        {
            MyCollection <Song> results = new MyCollection <Song>();

            foreach (KeyValuePair <string, ISearchParameter> kvp in searchParams)
            {
                foreach (Song song in collection)
                {
                    if (kvp.Value.checkSearchParam(song) && !results.Contains(song))
                    {
                        results.Add(song);
                    }
                }
            }

            return(results);
        }
 public void AddItemToCollection()
 {
     MyCollection.Add("Item");
     TestArray = getTestArray(MyCollection.Count);
 }
 public RomanianArmy(MyCollection soldiers)
 {
     army = soldiers;
 }
 public static void TestCapacityGet()
 {
     var collBase = new MyCollection(new string[10]);
     Assert.True(collBase.Capacity >= collBase.Count);
 }
 public Form1()
 {
     InitializeComponent();
     _submittedTests = new MyCollection();
     _outForChecking = new MyCollection();
 }
        public void ImportFileTest()
        {
            bool value = false;

            try
            {
                //string expectedFullName = "Glock G17 Imported unit test";
                string expectedFullName = "Glock G17 Open Class";
                if (MyCollection.Exists(_databasePath, expectedFullName, out _errOut))
                {
                    long gId = MyCollection.GetId(_databasePath, expectedFullName, out _errOut);
                    if (_errOut.Length > 0)
                    {
                        throw new Exception(_errOut);
                    }
                    if (!MyCollection.Delete(_databasePath, gId, out _errOut))
                    {
                        throw new Exception(_errOut);
                    }
                }

                if (!XmlImport.Details(_databasePath, _xmlImportFile, _ownerId, false, out _errOut))
                {
                    throw new Exception(_errOut);
                }
                long gunId = MyCollection.GetLastId(_databasePath, out _errOut);
                if (_errOut.Length > 0)
                {
                    throw new Exception(_errOut);
                }
                if (!XmlImport.Accessories(_databasePath, _xmlImportFile, gunId, out _errOut))
                {
                    throw new Exception(_errOut);
                }
                if (!XmlImport.BarrelConverstionKitDetails(_databasePath, _xmlImportFile, gunId, out _errOut))
                {
                    throw new Exception(_errOut);
                }
                if (!XmlImport.GunSmithDetails(_databasePath, _xmlImportFile, gunId, out _errOut))
                {
                    throw new Exception(_errOut);
                }
                if (!XmlImport.MaintanceDetails(_databasePath, _xmlImportFile, gunId, out _errOut))
                {
                    throw new Exception(_errOut);
                }

                List <GunCollectionList> lst = MyCollection.GetList(_databasePath, gunId, out _errOut);
                if (_errOut.Length > 0)
                {
                    throw new Exception(_errOut);
                }
                MyGunCollectionTest obj = new MyGunCollectionTest();
                obj.PrintList(lst);
                value = true;
            }
            catch (Exception e)
            {
                Console.WriteLine($"ERROR: {e.Message}");
            }
            General.HasTrueValue(value, _errOut);
        }
Example #43
0
 public MyEnumerator(MyCollection coll)
 {
     collection = coll;
     nIndex     = -1;
 }
Example #44
0
        public void TypedContractCollectionTest()
        {
            IWebHost host = ServiceHelper.CreateWebHostBuilder <TypedContractCollectionServiceStartup>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.BasicHttpBinding httpBinding = ClientHelper.GetBufferedModeBinding();
                var factory = new System.ServiceModel.ChannelFactory <ITypedContract_Collection>(httpBinding,
                                                                                                 new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/TypedContract_CollectionService.svc")));
                ITypedContract_Collection channel = factory.CreateChannel();

                foreach (int numItems in new int[] { 1, 5, 15, 50 })
                {
                    //arraylist
                    var outgoingAL = new ArrayList();
                    for (int item = 0; item < numItems; item++)
                    {
                        outgoingAL.Add(item);
                    }

                    ArrayList responseAL = channel.ArrayListMethod(outgoingAL);
                    Assert.Equal(outgoingAL.Count, responseAL.Count);
                    for (int item = 0; item < responseAL.Count; item++)
                    {
                        if ((int)responseAL[item] != (int)outgoingAL[item])
                        {
                            Assert.True(false, "ArrayList item validation failed");
                        }
                    }

                    //Collection
                    var outgoingCL = new Collection <string>();
                    for (int item = 0; item < numItems; item++)
                    {
                        string s = string.Format("Item " + item);
                        outgoingCL.Add(s);
                    }

                    Collection <string> responseCL = channel.CollectionOfStringsMethod(outgoingCL);
                    Assert.Equal(outgoingCL.Count, responseCL.Count);
                    for (int item = 0; item < responseCL.Count; item++)
                    {
                        if (responseCL[item].CompareTo(outgoingCL[item]) != 0)
                        {
                            Assert.True(false, "Collection item validation failed");
                        }
                    }

                    //CollecitonBase
                    MyCollection outgoingCB = new MyCollection();
                    for (int item = 0; item < numItems; item++)
                    {
                        outgoingCB.Add((short)item);
                    }

                    MyCollection responseCB = channel.CollectionBaseMethod(outgoingCB);
                    Assert.Equal(outgoingCB.Count, responseCB.Count);
                    for (int item = 0; item < responseCB.Count; item++)
                    {
                        if (responseCB[item] != outgoingCB[item])
                        {
                            Assert.True(false, "MyCollection:CollectionBase item validation failed");
                        }
                    }
                }
            }
        }
Example #45
0
/// <summary>
/// Generates the details.
/// </summary>
/// <param name="databasePath">The database path.</param>
/// <param name="gunId">The gun identifier.</param>
/// <param name="errOut">The error out.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.Exception"></exception>
        private static string GenerateDetails(string databasePath, long gunId, out string errOut)
        {
            string sAns = $"   <Details>{Environment.NewLine}";

            errOut = "";
            try
            {
                List <GunCollectionList> lst = MyCollection.GetList(databasePath, gunId, out errOut);
                if (errOut.Length > 0)
                {
                    throw  new Exception(errOut);
                }
                foreach (GunCollectionList l in lst)
                {
                    sAns += $"       <FullName>{StringHelper(l.FullName)}</FullName>{Environment.NewLine}";
                    sAns += $"       <Manufacturer>{StringHelper(l.Manufacturer)}</Manufacturer>{Environment.NewLine}";
                    sAns += $"       <ModelName>{StringHelper(l.ModelName)}</ModelName>{Environment.NewLine}";
                    sAns += $"       <SerialNumber>{StringHelper(l.SerialNumber)}</SerialNumber>{Environment.NewLine}";
                    sAns += $"       <Type>{StringHelper(l.Type)}</Type>{Environment.NewLine}";
                    sAns += $"       <Caliber>{StringHelper(l.Caliber)}</Caliber>{Environment.NewLine}";
                    sAns += $"       <Finish>{StringHelper(l.Finish)}</Finish>{Environment.NewLine}";
                    sAns += $"       <Condition>{StringHelper(l.Condition)}</Condition>{Environment.NewLine}";
                    sAns += $"       <CustomID>{StringHelper(l.CustomId)}</CustomID>{Environment.NewLine}";
                    sAns += $"       <NatID>{StringHelper(l.Nationality)}</NatID>{Environment.NewLine}";
                    sAns += $"       <GripID>{StringHelper(l.GripType)}</GripID>{Environment.NewLine}";
                    sAns += $"       <Weight>{StringHelper(l.Weight)}</Weight>{Environment.NewLine}";
                    sAns += $"       <Height>{StringHelper(l.Height)}</Height>{Environment.NewLine}";
                    sAns += $"       <BarrelLength>{StringHelper(l.BarrelLength)}</BarrelLength>{Environment.NewLine}";
                    sAns += $"       <BarWid>{StringHelper(l.BarrelWidth)}</BarWid>{Environment.NewLine}";
                    sAns += $"       <BarHei>{StringHelper(l.BarrelHeight)}</BarHei>{Environment.NewLine}";
                    sAns += $"       <Action>{StringHelper(l.Action)}</Action>{Environment.NewLine}";
                    sAns += $"       <Feedsystem>{StringHelper(l.FeedSystem)}</Feedsystem>{Environment.NewLine}";
                    sAns += $"       <Sights>{StringHelper(l.Sights)}</Sights>{Environment.NewLine}";
                    sAns += $"       <PurchasedPrice>{StringHelper(l.PurchasePrice)}</PurchasedPrice>{Environment.NewLine}";
                    sAns += $"       <PurchasedFrom>{StringHelper(l.PurchaseFrom)}</PurchasedFrom>{Environment.NewLine}";
                    sAns += $"       <AppraisedValue>{StringHelper(l.AppriasedValue)}</AppraisedValue>{Environment.NewLine}";
                    sAns += $"       <AppraisalDate>{StringHelper(l.AppraisalDate)}</AppraisalDate>{Environment.NewLine}";
                    sAns += $"       <AppraisedBy>{StringHelper(l.AppriasedBy)}</AppraisedBy>{Environment.NewLine}";
                    sAns += $"       <InsuredValue>{StringHelper(l.InsuredValue)}</InsuredValue>{Environment.NewLine}";
                    sAns += $"       <StorageLocation>{StringHelper(l.StorageLocation)}</StorageLocation>{Environment.NewLine}";
                    sAns += $"       <ConditionComments>{StringHelper(l.ConditionComments)}</ConditionComments>{Environment.NewLine}";
                    sAns += $"       <AdditionalNotes>{StringHelper(l.AdditionalNotes)}</AdditionalNotes>{Environment.NewLine}";
                    sAns += $"       <Produced>{StringHelper(l.DateProduced)}</Produced>{Environment.NewLine}";
                    sAns += $"       <IsCandR>{l.IsCAndR}</IsCandR>{Environment.NewLine}";
                    sAns += $"       <PetLoads>{StringHelper(l.PetLoads)}</PetLoads>{Environment.NewLine}";
                    sAns += $"       <dtp>{StringHelper(l.DateTimeAdded,true)}</dtp>{Environment.NewLine}";
                    sAns += $"       <Importer>{StringHelper(l.Importer)}</Importer>{Environment.NewLine}";
                    sAns += $"       <ReManDT>{StringHelper(l.RemanufactureDate,true)}</ReManDT>{Environment.NewLine}";
                    sAns += $"       <POI>{StringHelper(l.Poi)}</POI>{Environment.NewLine}";
                    sAns += $"       <SGChoke>{StringHelper(l.ShotGunChoke)}</SGChoke>{Environment.NewLine}";
                    sAns += $"       <Caliber3>{StringHelper(l.Caliber3)}</Caliber3>{Environment.NewLine}";
                    sAns += $"       <TwistOfRate>{StringHelper(l.TwistRate)}</TwistOfRate>{Environment.NewLine}";
                    sAns += $"       <TriggerPull>{StringHelper(l.TriggerPullInPounds)}</TriggerPull>{Environment.NewLine}";
                    sAns += $"       <BoundBook>{l.IsInBoundBook}</BoundBook>{Environment.NewLine}";
                    sAns += $"       <Classification>{StringHelper(l.Classification)}</Classification>{Environment.NewLine}";
                    sAns += $"       <DateofCR>{StringHelper(l.DateOfCAndR,true)}</DateofCR>{Environment.NewLine}";
                    sAns += $"       <IsClassIII>{l.IsClass3Item}</IsClassIII>{Environment.NewLine}";
                    sAns += $"       <ClassIiiOwner>{StringHelper(l.Class3Owner)}</ClassIiiOwner>{Environment.NewLine}";
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("GenerateDetails", e);
            }
            sAns += $"   </Details>{Environment.NewLine}";
            return(sAns);
        }
        public static void TestCapacity_SetInvalid()
        {
            var collBase = new MyCollection(new string[10]);
            Assert.Throws<ArgumentOutOfRangeException>(() => collBase.Capacity = -1); // Capacity < 0
            Assert.Throws<OutOfMemoryException>(() => collBase.Capacity = int.MaxValue); // Capacity is very large

            Assert.Throws<ArgumentOutOfRangeException>(() => collBase.Capacity = collBase.Count - 1); // Capacity < list.Count
        }
 public static void TestSyncRoot()
 {
     // SyncRoot should be the reference to the underlying collection, not to MyCollection
     var collBase = new MyCollection();
     object syncRoot = collBase.SyncRoot;
     Assert.NotEqual(syncRoot, collBase);
     Assert.Equal(collBase.SyncRoot, collBase.SyncRoot);
 }
Example #48
0
 public void Dispose()
 {
     _innerCurrent = null;
 }
        public static void TestCapacitySet(int capacity)
        {
            var collBase = new MyCollection(0);

            collBase.Capacity = capacity;
            Assert.Equal(capacity, collBase.Capacity);
        }
        public void Can_Serialize_MyCollection()
        {
            var dto = new MyCollection();

            Serialize(dto);
        }
Example #51
0
 public ThisEnumerator(MyCollection <T> toIterate)
 {
     _innerCurrent = toIterate;
 }
Example #52
0
 public Owner()
 {
     Items      = new MyCollection(this);
     KeyedItems = new MyKeyedCollection(this);
 }
Example #53
0
        public void TestInsertItself()
        {
            //
            // []  Insert itself into array list.
            //
            ArrayList arrList = new ArrayList((ICollection)strHeroes);

            ArrayList[] arrayListTypes = new ArrayList[] {
                            (ArrayList)arrList.Clone(),
                            (ArrayList)ArrayList.Adapter(arrList).Clone(),
                            (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                            (ArrayList)ArrayList.Synchronized(arrList).Clone()};

            int start = 3;
            foreach (ArrayList arrayListType in arrayListTypes)
            {
                arrList = arrayListType;
                // InsertRange values.
                arrList.InsertRange(start, arrList);

                // Verify InsertRange.
                for (int ii = 0; ii < arrList.Count; ++ii)
                {
                    string expectedItem;

                    if (ii < start)
                    {
                        expectedItem = strHeroes[ii];
                    }
                    else if (start <= ii && ii - start < strHeroes.Length)
                    {
                        expectedItem = strHeroes[ii - start];
                    }
                    else
                    {
                        expectedItem = strHeroes[(ii - strHeroes.Length)];
                    }

                    Assert.Equal(0, expectedItem.CompareTo((string)arrList[ii]));
                }

                //[] Verify that ArrayList does not pass the internal array to CopyTo
                arrList.Clear();
                for (int i = 0; i < 64; ++i)
                {
                    arrList.Add(i);
                }

                ArrayList arrInsert = new ArrayList();

                for (int i = 0; i < 4; ++i)
                {
                    arrInsert.Add(i);
                }

                MyCollection myCollection = new MyCollection(arrInsert);
                arrList.InsertRange(4, myCollection);

                Assert.Equal(0, myCollection.StartIndex);

                Assert.Equal(4, myCollection.Array.Length);
            }
        }
Example #54
0
    static void Main(string[] args)
    {
        Son o1 = new Son(5);
        Dad o3 = new OtherSon();
        Dad o2 = o1;

        // o1 = o3;
        // o1 = (Son)o3;
        o1 = o3 is Son ? (Son)o3 : null;
        o1 = o3 as Son;

        o1 = o3 as Son;

        Console.WriteLine(o1);

        OtherSon o4 = new OtherSon();

        Console.WriteLine("======================");
        o2.F();
        o4.F();
        o3.F();

        MyClass[] myObjects = { 5, 4, 3, 2, 1 };

        Array.Sort(myObjects);
        foreach (var o in myObjects)
        {
            Console.Write(" " + o.Number);
        }

        Console.WriteLine();

        //Console.WriteLine(o1.G<char, int>(5));

        MyClass o5 = 10;
        IComparable <MyClass> o6 = o5;

        Console.WriteLine(o6.CompareTo(new MyClass()
            {
                Number = 1
            }));

        MyCollection coll = new MyCollection();

        Console.WriteLine("###################");
        IEnumerator iter = coll.GetEnumerator();

        while (iter.MoveNext())
        {
            Console.Write(iter.Current);
        }
        Console.WriteLine();
        Console.WriteLine("###################");
        foreach (var element in coll)
        {
            if (element.Number > 5)
            {
                break;
            }
            Console.Write(element.Number);
        }

        Console.WriteLine();


        int counter = 15;

        foreach (int a in ArithSeq(1, 2))
        {
            if (--counter == 0)
            {
                break;
            }
            Console.Write(" " + a);
        }
        Console.WriteLine();
    }
Example #55
0
        public static void TestCapacityGet()
        {
            var collBase = new MyCollection(new string[10]);

            Assert.True(collBase.Capacity >= collBase.Count);
        }
 public MyCollectionDrop(MyCollection items)
 {
     _items = items;
 }
Example #57
0
 public ProducerViewModel(string name, string surname, DateTime birthDate, MyCollection <Film> films)
 {
     producer       = new Producer(name, surname, birthDate, films);
     producer.Films = films;
 }
Example #58
0
        static void Main(string[] args)
        {
            // 解决控制台中文乱码
            //Console.OutputEncoding = Encoding.GetEncoding(936);

            // 常量
            //const double PI = 3.14159;
            const string Const_Str = "Welcome to the C# Wrold.";

            Console.WriteLine(Const_Str);
            //Console.WriteLine(PI);

            // Array.cs
            //MyArray ar = new MyArray();
            var ar = new MyArray();

            ar.Run();

            //ReferenceTypes Rer = new ReferenceTypes();
            //Rer.DynamicType();

            // Enum.cs
            MyEnum e = new MyEnum();

            e.Run();

            // Interface.cs
            MyInterface Inter = new MyInterface();

            Inter.Run();

            // Method.cs
            MyMethod Met = new MyMethod();

            Met.Run();

            // Operators.cs
            MyOperators OP = new MyOperators();

            OP.Run();

            // RegularExpression.cs 正则表达式
            MyRegularExpression RE = new MyRegularExpression();

            RE.Run();

            // StringTest.cs
            MyString str = new MyString();

            str.Run();

            // StrucTest.cs
            MyStruc st = new MyStruc();

            st.Run();

            // VariAblesConst.cs
            InputCustomers i = new InputCustomers();

            i.InputCustomer("Please input Int:");

            // NameSpace.cs
            MyNameSpace NS = new MyNameSpace();

            NS.Run();

            // DataTypes.cs
            MyDataType DT = new MyDataType();

            DT.Run();

            // MultipleInherit.cs
            InheritClass02 Inh02 = new InheritClass02();

            Inh02.Run();

            // RectangleText RT = new RectangleText(10, 20);

            // Polymorphism.cs
            MyPolymorphism PP = new MyPolymorphism();

            PP.Run();

            // FilesTest.cs
            MyFiles file = new MyFiles();

            file.Run();

            // DirectoryTest.cs
            MyDirectory Dir = new MyDirectory();

            Dir.Run();

            // AttributeTest.cs
            MyAttributes AB = new MyAttributes();

            AB.Run();

            // PropertyTest.cs
            MyProperty pp = new MyProperty();

            pp.Run();

            // IndexerTest.cs
            var id = new MyIndexer(5);

            id.Run();

            // DelegateTest.cs
            var DL = new MyDelegate();

            DL.Run();

            //
            MyEvent ee = new MyEvent();

            ee.Run();

            // CollectionTest.cs
            MyCollection cc = new MyCollection();

            cc.Run();

            #region 预处理指令
            // #define 定义一个符号,这个符号会作为一个表达式传递给 #if 指令,这个判断会得到 ture 的 结果。
            //#if (PI)
            //            Console.WriteLine("PI is defined");
            //#else
            //            Console.WriteLine("PI is not defined");
            //#endif

            //#if (DEBUG && !VC_V10)
            //            Console.WriteLine("DEBUG is defined");
            //#elif (!DEBUG && VC_V10)
            //            Console.WriteLine("VC_V10 is defined");
            //#elif (DEBUG && VC_V10)
            //            Console.WriteLine("DEBUG and VC_V10 are defined");
            //#else
            //           Console.WriteLine("DEBUG and VC_V10 are not defined");
            //#endif
            #endregion

            // RandomNumber.cs
            MyRandom rd = new MyRandom();
            rd.Run();

            //
            MyTest tt = new MyTest();
            tt.Test();

            Console.ReadKey();
        }
Example #59
0
 public Firm()
 {
     Employees = new MyCollection <BaseEmployee>();
 }
Example #60
0
 public UserControl1()
 {
     // initialise collection with '1' - doesn't appear in design time properties
     Ids = new MyCollection <int>(1);
     InitializeComponent();
 }