Ejemplo n.º 1
0
        public Route Get(int id)
        {
            RouteFactory       routeFactory  = new RouteFactory();
            RouteTable <Route> instanceRoute = (RouteTable <Route>)routeFactory.GetRouteInstance();

            return(instanceRoute.Select(id));
        }
Ejemplo n.º 2
0
        public IEnumerable <Route> Get()
        {
            RouteFactory       routeFactory  = new RouteFactory();
            RouteTable <Route> instanceRoute = (RouteTable <Route>)routeFactory.GetRouteInstance();

            return(instanceRoute.Select());
        }
Ejemplo n.º 3
0
        public Collection <T> Select()
        {
            RouteFactory       routeFactory  = new RouteFactory();
            RouteTable <Route> instanceRoute = (RouteTable <Route>)routeFactory.GetRouteInstance();

            DriverFactory        driverFactory  = new DriverFactory();
            DriverTable <Driver> instanceDriver = (DriverTable <Driver>)driverFactory.GetDriverInstance();

            VehicleFactory         vehicleFactory  = new VehicleFactory();
            VehicleTable <Vehicle> instanceVehicle = (VehicleTable <Vehicle>)vehicleFactory.GetVehicleInstance();


            XDocument      xDoc       = XDocument.Load(Configuration.XMLFILEPATH);
            Collection <T> timetables = new Collection <T>();

            List <XElement> elements = xDoc.Descendants("Timetables").Descendants("Timetable").ToList();

            foreach (var element in elements)
            {
                Timetable timetable = new Timetable();
                timetable.id        = int.Parse(element.Attribute("id").Value);
                timetable.name      = element.Attribute("name").Value;
                timetable.departure = DateTime.Parse(element.Attribute("departure").Value);
                timetable.arrival   = DateTime.Parse(element.Attribute("arrival").Value);
                timetable.route     = instanceRoute.Select(int.Parse(element.Attribute("routeId").Value));
                timetable.driver    = instanceDriver.Select(int.Parse(element.Attribute("driverId").Value));
                timetable.vehicle   = instanceVehicle.Select(int.Parse(element.Attribute("vehicleId").Value));

                timetables.Add((T)timetable);
            }

            return(timetables);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 返回一个接口描述
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        public ApiDescriptor FindApi(IRequest request)
        {
            var req = (request ?? throw new ArgumentNullException(nameof(request))) as Request;

            if (req == null)
            {
                throw new ArgumentException($"{nameof(request)}类型只能是{typeof(Request).FullName}", nameof(request));
            }
            return(_route.Select(req.OwinContext));
        }