예제 #1
0
        public static IAirTravelManager Create(string manager)
        {
            IAirTravelManager airtravelManager = null;

            switch (manager)
            {
            case "Airline":
                airtravelManager = new AirLineManager();
                break;

            case "City":
                airtravelManager = new CityManager();
                break;

            case "Flight":
                airtravelManager = new FlightManager();
                break;

            case "Route":
                airtravelManager = new RouteManager();
                break;

            case "Schedule":
                airtravelManager = new ScheduleManager();
                break;
            }

            return(airtravelManager);
        }
        /// <summary>
        /// Method to create the manager objects using reflections and config file
        /// </summary>
        /// <param name="manager">String that represents the manager</param>
        /// <returns></returns>
        public static IAirTravelManager Create(string manager)
        {
            try
            {
                IAirTravelManager airtravelManager = null;
                AppSettingsReader asr = new AppSettingsReader();

                string mgrClassName = asr.GetValue(manager, typeof(string)).ToString();

                Assembly asm        = Assembly.GetExecutingAssembly();
                object   objManager = asm.CreateInstance(mgrClassName);
                airtravelManager = (IAirTravelManager)objManager;

                return(airtravelManager);
            }
            catch (AirlineManagerException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }