Add() публичный Метод

public Add ( CodeCatchClause value ) : int
value CodeCatchClause
Результат int
 public static CodeCatchClauseCollection Clone(this CodeCatchClauseCollection collection)
 {
     if (collection == null) return null;
     CodeCatchClauseCollection c = new CodeCatchClauseCollection();
     foreach (CodeCatchClause clause in collection)
         c.Add(clause.Clone());
     return c;
 }
Пример #2
0
		public void Constructor1_Deny_Unrestricted ()
		{
			CodeCatchClauseCollection coll = new CodeCatchClauseCollection (array);
			coll.CopyTo (array, 0);
			Assert.AreEqual (1, coll.Add (ccc), "Add");
			Assert.AreSame (ccc, coll[0], "this[int]");
			coll.AddRange (array);
			coll.AddRange (coll);
			Assert.IsTrue (coll.Contains (ccc), "Contains");
			Assert.AreEqual (0, coll.IndexOf (ccc), "IndexOf");
			coll.Insert (0, ccc);
			coll.Remove (ccc);
		}
		public void Constructor2 ()
		{
			CodeCatchClause cc1 = new CodeCatchClause ();
			CodeCatchClause cc2 = new CodeCatchClause ();

			CodeCatchClauseCollection c = new CodeCatchClauseCollection ();
			c.Add (cc1);
			c.Add (cc2);

			CodeCatchClauseCollection coll = new CodeCatchClauseCollection (c);
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (cc1), "#2");
			Assert.AreEqual (1, coll.IndexOf (cc2), "#3");
		}
		public void Remove ()
		{
			CodeCatchClause ccc1 = new CodeCatchClause ();
			CodeCatchClause ccc2 = new CodeCatchClause ();

			CodeCatchClauseCollection coll = new CodeCatchClauseCollection ();
			coll.Add (ccc1);
			coll.Add (ccc2);
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (ccc1), "#2");
			Assert.AreEqual (1, coll.IndexOf (ccc2), "#3");
			coll.Remove (ccc1);
			Assert.AreEqual (1, coll.Count, "#4");
			Assert.AreEqual (-1, coll.IndexOf (ccc1), "#5");
			Assert.AreEqual (0, coll.IndexOf (ccc2), "#6");
		}
		public void AddRange_Self ()
		{
			CodeCatchClauseCollection coll = new CodeCatchClauseCollection ();
			coll.Add (new CodeCatchClause ());
			Assert.AreEqual (1, coll.Count, "#1");
			coll.AddRange (coll);
			Assert.AreEqual (2, coll.Count, "#2");
		}
		public void AddRange ()
		{
			CodeCatchClause cc1 = new CodeCatchClause ();
			CodeCatchClause cc2 = new CodeCatchClause ();
			CodeCatchClause cc3 = new CodeCatchClause ();

			CodeCatchClauseCollection coll1 = new CodeCatchClauseCollection ();
			coll1.Add (cc1);
			coll1.Add (cc2);

			CodeCatchClauseCollection coll2 = new CodeCatchClauseCollection ();
			coll2.Add (cc3);
			coll2.AddRange (coll1);
			Assert.AreEqual (3, coll2.Count, "#1");
			Assert.AreEqual (1, coll2.IndexOf (cc1), "#2");
			Assert.AreEqual (2, coll2.IndexOf (cc2), "#3");
			Assert.AreEqual (0, coll2.IndexOf (cc3), "#4");

			CodeCatchClauseCollection coll3 = new CodeCatchClauseCollection ();
			coll3.Add (cc3);
			coll3.AddRange (new CodeCatchClause[] { cc1, cc2 });
			Assert.AreEqual (3, coll2.Count, "#5");
			Assert.AreEqual (1, coll2.IndexOf (cc1), "#6");
			Assert.AreEqual (2, coll2.IndexOf (cc2), "#7");
			Assert.AreEqual (0, coll2.IndexOf (cc3), "#8");
		}
		public void Add_Null () {
			CodeCatchClauseCollection coll = new CodeCatchClauseCollection ();
			coll.Add ((CodeCatchClause) null);
		}
Пример #8
0
 protected void Rewrite(CodeCatchClauseCollection target, CodeCatchClauseCollection source, ref bool didRewrite)
 {
     foreach (CodeCatchClause item in source)
     {
         target.Add(this.Rewrite(item, ref didRewrite));
     }
 }