コード例 #1
0
ファイル: CH0805.cs プロジェクト: PussInCode/Hello-World
        public CH0805()
        {
            Factory <Dog> doMaker = MakeDog;
            //Factory<Animal> animalMaker = doMaker;
            //Factory<Dog>和Factory<Animal>不是同一个对象,不存在继承关系

            FactoryOut <Dog>    dog    = MakeDog;
            FactoryOut <Animal> animal = dog;    //协变

            Console.WriteLine(animal().Legs.ToString());

            FactoryIn <Animal> animalIn = Animal;
            FactoryIn <Dog>    dogIn    = animalIn; //逆变

            dogIn(new Dog());
        }
コード例 #2
0
 public override void ProcessEntity(PicEntity entity)
 {
     if (entity is PicPoint point)
     {
         FactoryOut.AddPoint(point.LineType, point.Group, point.Layer, Multiplicator * point.Coord);
     }
     else if (entity is PicSegment seg)
     {
         FactoryOut.AddSegment(seg.LineType, seg.Group, seg.Layer, Multiplicator * seg.Pt0, Multiplicator * seg.Pt1);
     }
     else if (entity is PicArc arc)
     {
         FactoryOut.AddArc(arc.LineType, arc.Group, arc.Layer, Multiplicator * arc.Center, Multiplicator * arc.Radius, arc.AngleBeg, arc.AngleEnd);
     }
     else if (entity is PicNurb nurb)
     {
         FactoryOut.AddNurb(nurb.LineType, nurb.Group, nurb.Layer);
     }
     else if (entity is PicCotationDistance cotDist)
     {
         PicCotation.CotType eCotType = PicCotation.CotType.COT_DISTANCE;;
         if (entity is PicCotationDistance)
         {
             eCotType = PicCotation.CotType.COT_DISTANCE;
         }
         else if (entity is PicCotationHorizontal)
         {
             eCotType = PicCotation.CotType.COT_HORIZONTAL;
         }
         else if (entity is PicCotationVertical)
         {
             eCotType = PicCotation.CotType.COT_VERTICAL;
         }
         FactoryOut.AddCotation(eCotType, cotDist.Group, cotDist.Layer, Multiplicator * cotDist.Pt0, Multiplicator * cotDist.Pt1, Multiplicator * cotDist.Offset, cotDist.Text, 1);
     }
 }