示例#1
0
        static void Main(string[] args)
        {
            var list = new List <MapObject>
            {
                new Hotel {
                    Name = "Hilton", Latitude = 34.4, Longitude = 27.8, Stars = 5
                },
                new Restaurant {
                    Name = "Italia", Latitude = 36.7, Longitude = 30.1, Cuisine = Cuisine.Italian
                },
                new BusStation {
                    Name = "28 May", Latitude = 15.1, Longitude = 27.5, BusNumbers = { 26, 48, 55, 96 }
                }
            };

            foreach (var item in list)
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }

            var exporter = new MapObjectExporter();

            foreach (var item in list)
            {
                item.Export(exporter);
            }

            //var exporter = new MapObjectExporter();
            //foreach (var item in list)
            //{
            //    if (item is Hotel)
            //        exporter.ExportHotel(item as Hotel);

            //    if (item is Restaurant)
            //        exporter.ExportRestaurant(item as Restaurant);

            //    if (item is BusStation)
            //        exporter.ExportBusStation(item as BusStation);
            //}
        }
示例#2
0
        static void Main(string[] args)
        {
            List <MapObject> mapObjects = new List <MapObject>();

            mapObjects.Add(new Hotel()
            {
                Name = "Absheron", Latitude = 40.12, Longitude = 41.34, Stars = 5
            });
            mapObjects.Add(new Restaurant()
            {
                Name = "Sheki", Latitude = 43.25, Longitude = 45.34, Cuisine = Cuisine.Traditional
            });
            mapObjects.Add(new BusStop()
            {
                Name = "28 May", Latitude = 41.22, Longitude = 43.78, BusNumbers = { 1, 2, 14 }
            });
            MapObjectExporter exporter = new MapObjectExporter();

            foreach (var obj in mapObjects)
            {
                obj.Export(exporter);

                //if (obj is Hotel)
                //{
                //    exporter.ExportHotel(obj as Hotel);
                //}
                //if (obj is Restaurant)
                //{
                //    exporter.ExportRestaurant(obj as Restaurant);
                //}
                //if (obj is BusStop)
                //{
                //    exporter.ExportBusStop(obj as BusStop);
                //}
            }
        }
示例#3
0
 public override void Export(MapObjectExporter exporter)
 {
     exporter.ExportRestaurant(this);
 }
示例#4
0
 public override void Export(MapObjectExporter exporter)
 {
     exporter.ExportHotel(this);
 }
示例#5
0
 public abstract void Export(MapObjectExporter exporter);
示例#6
0
 public override void Export(MapObjectExporter exporter)
 {
     exporter.ExportBusStation(this);
 }