public LenientGTFSFeed(IGTFSDataSource source) { DataSource = source; Agencies = new IDEntityCollection <Agency>(DataSource, "agency", AgencyFactory); DefaultAgencyID = Agencies.First().ID; Routes = new IDEntityCollection <Route>(DataSource, "routes", RouteFactory); Calendars = new GTFSCalendarCollection(DataSource, new IDEntityCollection <Calendar>(DataSource, "calendar", CalendarFactory), new TwoKeyEntityCollection <CalendarDate, string, NodaTime.LocalDate>(DataSource, "calendar_dates", CalendarDateFactory) ); Stops = new IDEntityCollection <Stop>(DataSource, "stops", StopFactory); Trips = new IDEntityCollection <Trip>(DataSource, "trips", TripFactory); StopTimes = new GTFSOrderedEntityCollection <StopTime>(DataSource, "stop_times", StopTimeFactory); FareAttributes = new IDEntityCollection <FareAttribute>(DataSource, "fare_attributes", FareAttributeFactory); ShapePoints = new GTFSOrderedEntityCollection <ShapePoint>(DataSource, "shapes", ShapePointFactory); Frequencies = new TwoKeyEntityCollection <Frequency, string, Duration>(DataSource, "frequencies", FrequencyFactory); Transfers = new TwoKeyEntityCollection <Transfer, string, string>(DataSource, "transfers", TransferFactory); Pathways = new IDEntityCollection <Pathway>(DataSource, "pathways", PathwayFactory); Levels = new IDEntityCollection <Level>(DataSource, "levels", LevelFactory); Translations = new GTFSGenericCollection <Translation>(DataSource, "translations", TranslationFactory); Attributions = new GTFSGenericCollection <Attribution>(DataSource, "attributions", AttributionFactory); FeedInfo = null; foreach (FeedInfo info in DataSource.GetObjects("feed_info", FeedInfoFactory, new List <GTFSUnparsedEntity>())) { FeedInfo = info; break; } }
public static void AssertForeignKeyExists(string input, string key, GTFSCalendarCollection collection, string collectionName) { if (input == null) { throw new PropertyNullException(key); } if (!collection.Contains(input)) { if (input == "") { throw new PropertyNullException(key); } else { throw new PropertyForeignKeyException(key, $"The collection {collectionName} doesn't contain the key {input}."); } } }
public static void AssertForeignKeyExists(this GTFSPropertyCollection properties, string key, GTFSCalendarCollection collection, string collectionName) => AssertForeignKeyExists(properties[key], key, collection, collectionName);