示例#1
0
        protected CodeStatement[] GetCommentHeader(string sectionTitle)
        {
            CodeCommentStatementCollection comments = new CodeCommentStatementCollection(_headercomment);

            comments.Insert(2, new CodeCommentStatement(sectionTitle));
            CodeCommentStatement[] statements = new CodeCommentStatement[comments.Count];
            comments.CopyTo(statements, 0);
            return(statements);
        }
        public void Constructor1_Deny_Unrestricted()
        {
            CodeCommentStatementCollection coll = new CodeCommentStatementCollection(array);

            coll.CopyTo(array, 0);
            Assert.AreEqual(1, coll.Add(ccs), "Add");
            Assert.AreSame(ccs, coll[0], "this[int]");
            coll.AddRange(array);
            coll.AddRange(coll);
            Assert.IsTrue(coll.Contains(ccs), "Contains");
            Assert.AreEqual(0, coll.IndexOf(ccs), "IndexOf");
            coll.Insert(0, ccs);
            coll.Remove(ccs);
        }
示例#3
0
        public void Insert()
        {
            CodeCommentStatement ccs1 = new CodeCommentStatement();
            CodeCommentStatement ccs2 = new CodeCommentStatement();

            CodeCommentStatementCollection coll = new CodeCommentStatementCollection();

            coll.Add(ccs1);
            Assert.AreEqual(1, coll.Count, "#1");
            Assert.AreEqual(0, coll.IndexOf(ccs1), "#2");
            coll.Insert(0, ccs2);
            Assert.AreEqual(2, coll.Count, "#3");
            Assert.AreEqual(1, coll.IndexOf(ccs1), "#4");
            Assert.AreEqual(0, coll.IndexOf(ccs2), "#5");
        }
示例#4
0
        public void Insert_Null()
        {
            CodeCommentStatementCollection coll = new CodeCommentStatementCollection();

            coll.Insert(0, (CodeCommentStatement)null);
        }
示例#5
0
        // CodeCommentStatementCollection
        public void CodeCommentStatementCollectionExample()
        {
            //<Snippet1>
            //<Snippet2>
            // Creates an empty CodeCommentStatementCollection.
            CodeCommentStatementCollection collection = new CodeCommentStatementCollection();

            //</Snippet2>

            //<Snippet3>
            // Adds a CodeCommentStatement to the collection.
            collection.Add(new CodeCommentStatement("Test comment"));
            //</Snippet3>

            //<Snippet4>
            // Adds an array of CodeCommentStatement objects to the collection.
            CodeCommentStatement[] comments = { new CodeCommentStatement("Test comment"), new CodeCommentStatement("Another test comment") };
            collection.AddRange(comments);

            // Adds a collection of CodeCommentStatement objects to the collection.
            CodeCommentStatementCollection commentsCollection = new CodeCommentStatementCollection();

            commentsCollection.Add(new CodeCommentStatement("Test comment"));
            commentsCollection.Add(new CodeCommentStatement("Another test comment"));
            collection.AddRange(commentsCollection);
            //</Snippet4>

            //<Snippet5>
            // Tests for the presence of a CodeCommentStatement in the
            // collection, and retrieves its index if it is found.
            CodeCommentStatement testComment = new CodeCommentStatement("Test comment");
            int itemIndex = -1;

            if (collection.Contains(testComment))
            {
                itemIndex = collection.IndexOf(testComment);
            }
            //</Snippet5>

            //<Snippet6>
            // Copies the contents of the collection, beginning at index 0,
            // to the specified CodeCommentStatement array.
            // 'comments' is a CodeCommentStatement array.
            collection.CopyTo(comments, 0);
            //</Snippet6>

            //<Snippet7>
            // Retrieves the count of the items in the collection.
            int collectionCount = collection.Count;

            //</Snippet7>

            //<Snippet8>
            // Inserts a CodeCommentStatement at index 0 of the collection.
            collection.Insert(0, new CodeCommentStatement("Test comment"));
            //</Snippet8>

            //<Snippet9>
            // Removes the specified CodeCommentStatement from the collection.
            CodeCommentStatement comment = new CodeCommentStatement("Test comment");

            collection.Remove(comment);
            //</Snippet9>

            //<Snippet10>
            // Removes the CodeCommentStatement at index 0.
            collection.RemoveAt(0);
            //</Snippet10>
            //</Snippet1>
        }