Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void AddRange()
        {
            CodeParameterDeclarationExpression param1 = new CodeParameterDeclarationExpression();
            CodeParameterDeclarationExpression param2 = new CodeParameterDeclarationExpression();
            CodeParameterDeclarationExpression param3 = new CodeParameterDeclarationExpression();

            CodeParameterDeclarationExpressionCollection coll1 = new CodeParameterDeclarationExpressionCollection();

            coll1.Add(param1);
            coll1.Add(param2);

            CodeParameterDeclarationExpressionCollection coll2 = new CodeParameterDeclarationExpressionCollection();

            coll2.Add(param3);
            coll2.AddRange(coll1);
            Assert.AreEqual(3, coll2.Count, "#1");
            Assert.AreEqual(1, coll2.IndexOf(param1), "#2");
            Assert.AreEqual(2, coll2.IndexOf(param2), "#3");
            Assert.AreEqual(0, coll2.IndexOf(param3), "#4");

            CodeParameterDeclarationExpressionCollection coll3 = new CodeParameterDeclarationExpressionCollection();

            coll3.Add(param3);
            coll3.AddRange(new CodeParameterDeclarationExpression[] { param1, param2 });
            Assert.AreEqual(3, coll2.Count, "#5");
            Assert.AreEqual(1, coll2.IndexOf(param1), "#6");
            Assert.AreEqual(2, coll2.IndexOf(param2), "#7");
            Assert.AreEqual(0, coll2.IndexOf(param3), "#8");
        }
Ejemplo n.º 3
0
        public void AddRange_Self()
        {
            CodeParameterDeclarationExpressionCollection coll = new CodeParameterDeclarationExpressionCollection();

            coll.Add(new CodeParameterDeclarationExpression());
            Assert.AreEqual(1, coll.Count, "#1");
            coll.AddRange(coll);
            Assert.AreEqual(2, coll.Count, "#2");
        }
Ejemplo n.º 4
0
        public CodeParameterDeclarationExpressionCollection GenerateConstructorParameter(Activity groupActivity)
        {
            var parameters = new CodeParameterDeclarationExpressionCollection();

            foreach (var activity in ((GroupActivity)groupActivity).Activities)
            {
                var activityBuilder = activityBuilderFactory.Get(activity.Type);
                parameters.AddRange(activityBuilder.GenerateConstructorParameter(activity));
            }

            return(parameters);
        }
Ejemplo n.º 5
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>
        }
Ejemplo n.º 6
0
        public void AddRange_Null_Collection()
        {
            CodeParameterDeclarationExpressionCollection coll = new CodeParameterDeclarationExpressionCollection();

            coll.AddRange((CodeParameterDeclarationExpressionCollection)null);
        }
Ejemplo n.º 7
0
        public void AddRange_Null_Item()
        {
            CodeParameterDeclarationExpressionCollection coll = new CodeParameterDeclarationExpressionCollection();

            coll.AddRange(new CodeParameterDeclarationExpression[] { null });
        }