示例#1
0
    private static MySpecialCollectionList <IBeast> GetSpecialCollectionList()
    {
        var ant = new Ant()
        {
            Name = "Mr Ant"
        };
        var cat = new Cat()
        {
            Name = "Mr Cat"
        };
        var dog = new Dog()
        {
            Name = "Mr Dog"
        };
        var Special            = new Special <IBeast>(ant);
        var specialCollection1 = new MySpecialCollection <IBeast>()
        {
            Items =
            { new Special <IBeast>(ant),
              new Special <IBeast>(cat),
              new Special <IBeast>(dog) }
        };

        specialCollection1.Name = "Special Collection1";
        var specialCollection2 = new MySpecialCollection <IBeast>()
        {
            Items =
            { new Special <IBeast>(ant),
              new Special <IBeast>(dog) }
        };

        specialCollection2.Name = "Special Collection2";
        var specialCollectionList = new MySpecialCollectionList <IBeast>()
        {
            Items =
            {
                specialCollection1, specialCollection2
            }
        };

        specialCollectionList.Name = "Special Collection List";
        return(specialCollectionList);
    }
 public static bool LongerThanFiveElements(this MySpecialCollection collection)
 {
     return(collection.NumberOfElements() > 5);
 }