Ejemplo n.º 1
0
    public static void Main()
    {
        ///////////////////////////////////////////////
        /// QUERY INTERFACE/ RT type Checking
        ///////////////////////////////////////////////
        try
        {
            AirlineInfo            objAirlineInfo;
            IAirportFacilitiesInfo objFacilitiesInfo;

            // Create a new AirlineInfo object
            objAirlineInfo = new AirlineInfo();

            // Invoke the GetAirlineTiming method
            String strDetails = objAirlineInfo.GetAirlineTiming
                                    (strAirline);

            // QI for the IAirportFacilitiesInfo interface
            objFacilitiesInfo = (IAirportFacilitiesInfo)objAirlineInfo;

            //Invoke a method on the IAirportFacilitiesInfo interface
            Console.WriteLine("{0}",
                              objFacilitiesInfo.GetInternetCafeLocations());
        }
        catch (InvalidCastException eCast)
        {
            Console.WriteLine("We got an InvalidCast Exception " +
                              "- Message is {0}", eCast.Message);
        }
    }
Ejemplo n.º 2
0
    public static void Main()
    {
        ///////////////////////////////////////////////
        /// EARLY BINDING EXAMPLE
        ///////////////////////////////////////////////
        String strAirline           = "Air Scooby IC 5678";
        String strFoodJunkieAirline = "Air Jughead TX 1234";

        try
        {
            AirlineInfo objAirlineInfo;

            // Create a new AirlineInfo Object
            objAirlineInfo = new AirlineInfo();

            // Display the output after calling
            // the GetAirileTiming method.
            Console.WriteLine("Details for Airline {0} --> {1}",
                              strAirline, objAirlineInfo.GetAirlineTiming(strAirline));

            // ERROR: The following will result in a thrown exception!
            // Console.WriteLine("Details for Airline {0} --> {1}",
            // strFoodJunkieAirline,objAirlineInfo.GetAirlineTiming
            // (strFoodJunkieAirline));
        }
        catch (COMException e)
        {
            Console.WriteLine("Oops- We encountered an error " +
                              "for Airline {0}. The Error message " +
                              "is : {1}. The  Error code is {2}",
                              strFoodJunkieAirline,
                              e.Message, e.ErrorCode);
        }
    }
 public AirlineInfoController(IOptions <AirlineInfo> airlineInfoWrapper)
 {
     this.airlineInfo = airlineInfoWrapper.Value;
 }