示例#1
0
        public void Constructor1_Deny_Unrestricted()
        {
            CodeParameterDeclarationExpressionCollection coll = new CodeParameterDeclarationExpressionCollection(array);

            coll.CopyTo(array, 0);
            Assert.AreEqual(1, coll.Add(cpde), "Add");
            Assert.AreSame(cpde, coll[0], "this[int]");
            coll.AddRange(array);
            coll.AddRange(coll);
            Assert.IsTrue(coll.Contains(cpde), "Contains");
            Assert.AreEqual(0, coll.IndexOf(cpde), "IndexOf");
            coll.Insert(0, cpde);
            coll.Remove(cpde);
        }
示例#2
0
        // CodeParameterDeclarationExpressionCollection
        public void CodeParameterDeclarationExpressionCollectionExample()
        {
            //<Snippet1>
            //<Snippet2>
            // Creates an empty CodeParameterDeclarationExpressionCollection.
            CodeParameterDeclarationExpressionCollection collection = new CodeParameterDeclarationExpressionCollection();

            //</Snippet2>

            //<Snippet3>
            // Adds a CodeParameterDeclarationExpression to the collection.
            collection.Add(new CodeParameterDeclarationExpression(typeof(int), "testIntArgument"));
            //</Snippet3>

            //<Snippet4>
            // Adds an array of CodeParameterDeclarationExpression objects
            // to the collection.
            CodeParameterDeclarationExpression[] parameters = { new CodeParameterDeclarationExpression(typeof(int), "testIntArgument"), new CodeParameterDeclarationExpression(typeof(bool), "testBoolArgument") };
            collection.AddRange(parameters);

            // Adds a collection of CodeParameterDeclarationExpression objects
            // to the collection.
            CodeParameterDeclarationExpressionCollection parametersCollection = new CodeParameterDeclarationExpressionCollection();

            parametersCollection.Add(new CodeParameterDeclarationExpression(typeof(int), "testIntArgument"));
            parametersCollection.Add(new CodeParameterDeclarationExpression(typeof(bool), "testBoolArgument"));
            collection.AddRange(parametersCollection);
            //</Snippet4>

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

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

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

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

            //</Snippet7>

            //<Snippet8>
            // Inserts a CodeParameterDeclarationExpression at index 0
            // of the collection.
            collection.Insert(0, new CodeParameterDeclarationExpression(typeof(int), "testIntArgument"));
            //</Snippet8>

            //<Snippet9>
            // Removes the specified CodeParameterDeclarationExpression
            // from the collection.
            CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(typeof(int), "testIntArgument");

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

            //<Snippet10>
            // Removes the CodeParameterDeclarationExpression at index 0.
            collection.RemoveAt(0);
            //</Snippet10>
            //</Snippet1>
        }
 public bool Contains(DynaArgument thisArg)
 {
     return(codeArgs.Contains(thisArg.CodeArgument));
 }