NArrange.Core.CodeElements.TypeParameter.AddConstraint C# (CSharp) Method

AddConstraint() public method

Adds a constraint for the type parameter.
public AddConstraint ( string constraint ) : void
constraint string The constraint.
return void
        public void AddConstraint(string constraint)
        {
            BaseConstraints.Add(constraint);
        }

Usage Example

Example #1
0
        public void CloneTest()
        {
            TypeParameter typeParameter = new TypeParameter();
            typeParameter.Name = "T";
            typeParameter.AddConstraint("IDisposable");
            typeParameter.AddConstraint("new()");

            TypeParameter clone = typeParameter.Clone() as TypeParameter;
            Assert.IsNotNull(clone, "Clone should return a TypeParameter instance.");

            Assert.AreEqual(typeParameter.Name, clone.Name, "Name property was not copied correctly.");
            Assert.AreEqual(typeParameter.Constraints.Count, clone.Constraints.Count, "Constraints property was not copied correctly.");
            Assert.AreEqual(typeParameter.Constraints[0], clone.Constraints[0], "Constraints property was not copied correctly.");
            Assert.AreEqual(typeParameter.Constraints[1], clone.Constraints[1], "Constraints property was not copied correctly.");
        }
All Usage Examples Of NArrange.Core.CodeElements.TypeParameter::AddConstraint