Пример #1
0
 public ClassClonable()
 {
     field = 55;
     sProp = "xyx";
     ap    = new AirPlanes {
         EnginesNr = 3
     };
 }
Пример #2
0
 public void ChangeData()
 {
     field = 98;
     sProp = "ijk";
     ap    = new AirPlanes {
         EnginesNr = 78
     };
 }
Пример #3
0
        public static void Run()
        {
            AirPlanes ap = new AirPlanes();

            Console.WriteLine(ap[5]);
            if (ap is IAirCraft)
            {
                Console.WriteLine("Ap is IAirCraft");
            }

            IAirCraft airCraft = ap as IAirCraft;

            ap = airCraft as AirPlanes;
            ap = (AirPlanes)airCraft;

            AirPlanes  ab  = ap as AirPlanes;
            AirPlanes  ab2 = airCraft as AirPlanes;
            ICloneable icl = airCraft as ICloneable;

            if (icl != null)
            {
                Console.WriteLine("IClonable");
            }
            else
            {
                Console.WriteLine("NOT!");
            }


            ClassEnumerable ce = new ClassEnumerable();

            foreach (var t in ce)
            {
                Console.WriteLine(t);
            }
            foreach (var r in ce.GetInt(true))
            {
                Console.WriteLine(r);
            }



            /**********************/
            ClassClonable cc      = new ClassClonable();
            ClassClonable ccClone = cc.Clone() as ClassClonable;

            cc.ShowData();
            ccClone.ShowData();
            cc.ChangeData();


            cc.ShowData();
            ccClone.ShowData();

            ClassClonable deepCopied = cc.DeepCopy();

            Console.WriteLine("Deep Copy");

            deepCopied.ShowData();
            /**********************************/
            ClassComparable        comp1    = new ClassComparable("pokolorowany");
            ClassComparable        comp2    = new ClassComparable("powietrze");
            ClassComparable        comp3    = new ClassComparable("co");
            ClassComparable        comp4    = new ClassComparable("kazdy");
            ClassComparable        comp5    = new ClassComparable("tyl");
            List <ClassComparable> compList = new List <ClassComparable>()
            {
                comp1, comp2, comp3, comp4, comp5
            };

            compList.Sort();
            foreach (var t in compList)
            {
                Console.WriteLine(t.Name);
            }


            compList.Sort(new NamingComparer());
            foreach (var t in compList)
            {
                Console.WriteLine(t.Name);
            }


            comp1.CompareTo(comp2);


            //   if (comp1 > comp2) Console.WriteLine("OK");
        }