public Frequency(CSVRowItem item) { mTripID = item["trip_id"]; mStartTime = item["start_time"].ToTimeSpan(); mEndTime = item["end_time"].ToTimeSpan(); mHeadwaySecs = int.Parse(item["headway_secs"]); }
/// <summary> /// This is the CSV row item constructor. /// </summary> /// <param name="item">The CSV row item.</param> public Route(CSVRowItem item) { mRouteID = item.ValidateNotEmptyOrNull("route_id"); mAgencyID = item["agency_id"]; mLongName = item["route_long_name"]; mShortName = item["route_short_name"]; if ((mShortName == null || mShortName == "") && (mLongName == null || mLongName == "")) throw new ArgumentException("Must specify either route_long_name or route_short_name"); if (mShortName == null || mShortName == "") mShortName = mLongName; else if (mLongName == null || mLongName == "") mLongName = mShortName; mDesc = item["route_desc"]; mRouteType=item["route_type"].ToRouteType(); string url = item["route_url"]; mRouteUrl = url == null || url ==""?null:new Uri(url); mRouteColor = item["route_color"]; mRouteTextColor = item["route_text_color"]; }
/// <summary> /// This is the CSV row item constructor. /// </summary> /// <param name="item">The CSV row item.</param> public Route(CSVRowItem item) { mRouteID = item.ValidateNotEmptyOrNull("route_id"); mAgencyID = item["agency_id"]; mLongName = item["route_long_name"]; mShortName = item["route_short_name"]; if ((mShortName == null || mShortName == "") && (mLongName == null || mLongName == "")) { throw new ArgumentException("Must specify either route_long_name or route_short_name"); } if (mShortName == null || mShortName == "") { mShortName = mLongName; } else if (mLongName == null || mLongName == "") { mLongName = mShortName; } mDesc = item["route_desc"]; mRouteType = item["route_type"].ToRouteType(); string url = item["route_url"]; mRouteUrl = url == null || url == ""?null:new Uri(url); mRouteColor = item["route_color"]; mRouteTextColor = item["route_text_color"]; }
private void CreateRowItems() { rowItems = new CSVRowItem[itemCount]; for (int rowIndex = 0; rowIndex < itemCount; rowIndex++) { rowItems [rowIndex] = new CSVRowItem(values [rowIndex], indexForAttribName); } }
/// <summary> /// This is the CSVRowItem constructor. /// </summary> /// <param name="item">The row item.</param> public CalendarDate(CSVRowItem item) { //service_id,date,exception_type mServiceID = item.ValidateNotEmptyOrNull("service_id"); mDate = item["date"].ToDate(); mExceptionType=item["exception_type"].ToCalendarExceptionType(); }
/// <summary> /// This is the CSVRowItem constructor. /// </summary> /// <param name="item">The row item.</param> public CalendarDate(CSVRowItem item) { //service_id,date,exception_type mServiceID = item.ValidateNotEmptyOrNull("service_id"); mDate = item["date"].ToDate(); mExceptionType = item["exception_type"].ToCalendarExceptionType(); }
/// <summary> /// This constructor sets the default values from the CSVRowItem. /// </summary> /// <param name="item">The item.</param> public FareRule(CSVRowItem item) { mFareID = item.ValidateNotEmptyOrNull("fare_id"); mRouteID = item["route_id"]; mOriginID = item["origin_id"]; mDestinationID = item["destination_id"]; mContainsID = item["contains_id"]; }
/// <summary> /// This is the CSV item constructor. /// </summary> /// <param name="item">The csv item.</param> public Agency(CSVRowItem item) { mAgencyID = item["agency_id"]; mName = item.ValidateNotEmptyOrNull("agency_name"); mUrl = new Uri(item.ValidateNotEmptyOrNull("agency_url")); mTimeZone = item.ValidateNotEmptyOrNull("agency_timezone"); mLang = item["agency_lang"]; mPhone = item["agency_phone"]; }
/// <summary> /// shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence,shape_dist_traveled /// </summary> /// <param name="item"></param> public Shape(CSVRowItem item) { mID = item["shape_id"]; mPtLat = decimal.Parse(item["shape_pt_lat"]); mPtLon = decimal.Parse(item["shape_pt_lon"]); int outPtSequence; mPtSequence = int.TryParse(item["shape_pt_sequence"], out outPtSequence)?outPtSequence:(int?)null; mDistTraveled = item["shape_dist_traveled"]; }
public static string ValidateNotEmptyOrNull(this CSVRowItem item, string field) { string data = item[field]; if (data == null || data == "") { throw new ArgumentNullException(string.Format(@"Missing mandatory field ""{0}"" at line {1}", field, item.LineID)); } return(data); }
public FareAttribute(CSVRowItem item) { mFareID = item.ValidateNotEmptyOrNull("fare_id"); mPrice = decimal.Parse(item["price"]); mCurrencyType = item.ValidateNotEmptyOrNull("currency_type"); mPaymentMethod = item["payment_method"].ToPaymentMethodType(); mTransfers = item["transfers"].ToTransferType(); int tDur; mTransferDuration = int.TryParse(item["transfer_duration"], out tDur) ? tDur : (int?)null; }
/// <summary> /// This is the csv row item constructor. /// </summary> /// <param name="item">The csv row item object to populate the structure.</param> public Transfer(CSVRowItem item) { //from_stop_id,to_stop_id,transfer_type,min_transfer_time mFromStopID = item.ValidateNotEmptyOrNull("from_stop_id"); mToStopID = item.ValidateNotEmptyOrNull("to_stop_id"); mTransferType = item["transfer_type"].ToTransferOptionsType(); int minTrans; mMinTransferTime = int.TryParse(item["min_transfer_time"], out minTrans)?minTrans:(int?)null; }
/// <summary> /// The CSV item constructor. /// </summary> /// <param name="item">The CSV row item.</param> public Trip(CSVRowItem item) { mRouteID = item.ValidateNotEmptyOrNull("route_id"); mServiceID = item.ValidateNotEmptyOrNull("service_id"); mTripID = item.ValidateNotEmptyOrNull("trip_id"); mHeadSign = item["trip_headsign"]; mShortName = item["trip_short_name"]; mDirectionID = item["direction_id"].ToDirectionType(); mBlockID = item["block_id"]; mShapeID = item["shape_id"]; }
public Calendar(CSVRowItem item) { mServiceID = item.ValidateNotEmptyOrNull("service_id"); mMonday = item.ValidateNotEmptyOrNull("monday") == "1"; mTuesday = item.ValidateNotEmptyOrNull("tuesday") == "1"; mWednesday = item.ValidateNotEmptyOrNull("wednesday") == "1"; mThursday = item.ValidateNotEmptyOrNull("thursday") == "1"; mFriday = item.ValidateNotEmptyOrNull("friday") == "1"; mSaturday = item.ValidateNotEmptyOrNull("saturday") == "1"; mSunday = item.ValidateNotEmptyOrNull("sunday") == "1"; mDateStart = item["start_date"].ToDate(); mDateEnd = item["end_date"].ToDate(); }
public void TestCSVRowItem_SimpleLine() { CSVRowItem item1 = new CSVRowItem(CSVStreamOptions.Default , "123456789ABCDEFG".ToCharArray() , new KeyValuePair<int,int>[] { new KeyValuePair<int,int>(0,0) ,new KeyValuePair<int,int>(0,4) ,new KeyValuePair<int,int>(4,3) ,new KeyValuePair<int,int>(7,3) ,new KeyValuePair<int,int>(10,6) }); string[] items = item1.ToArray(); Assert.IsTrue(items.Length == 5); }
/// <summary> /// This constructor allows the data to be polulated by the CSVRowItem string. /// </summary> /// <param name="item">The row item.</param> public StopTime(CSVRowItem item) { mTripID = item["trip_id"]; mArrivalTime = item["arrival_time"].ToTimeSpan(); mDepartureTime = item["departure_time"].ToTimeSpan(); mStopID = item["stop_id"]; mStopSequence = int.Parse(item["stop_sequence"]); mStopHeadSign = item["stop_headsign"]; mPickUpType = item["pickup_type"].ToPickUpType(); mDropOffType = item["drop_off_type"].ToDropOffType(); mShapeDistTraveled = item["shape_dist_traveled"]; }
/// <summary> /// This is the default constructor /// </summary> /// <param name="item"></param> public Stop(CSVRowItem item) { mID = item.ValidateNotEmptyOrNull("stop_id"); mCode = item["stop_code"]; mName = item.ValidateNotEmptyOrNull("stop_name"); mDesc = item["stop_desc"]; mLon = decimal.Parse(item["stop_lon"]); mLat = decimal.Parse(item["stop_lat"]); mZoneID = item["zone_id"]; string uri = item["stop_url"]; mUrl = (uri == null || uri == "") ? (Uri)null : new Uri(uri); mLocationType = item["location_type"].ToLocationType(); mParentStation = item["parent_station"]; }
private void CreateRowItems() { rowItems = new CSVRowItem[itemCount]; for (int rowIndex = 0; rowIndex < itemCount; rowIndex++) { rowItems [rowIndex] = new CSVRowItem (values [rowIndex],indexForAttribName); } }