Beispiel #1
0
 public static async Task SaveAgency(TransitAgency agency, string[] routes)
 {
     await AccessAgencyCache(delegate(List <Tuple <TransitAgency, string[]> > agencies)
     {
         if (!agencies.Any(item => item.Item1 == agency))
         {
             agencies.Add(new Tuple <TransitAgency, string[]>(agency, routes));
             return(true);
         }
         return(false);
     });
 }
        public static List <Tuple <TransitAgency, string[]> > DeformatAgencies(CompactFormatReader reader)
        {
            List <Tuple <TransitAgency, string[]> > result = new List <Tuple <TransitAgency, string[]> >();

            CompactFormatReader[] agencyReader;
            List <string>         routes;

            while ((agencyReader = reader.Next()) != null)
            {
                TransitAgency agency = new TransitAgency();
                agency.ID   = agencyReader[0].ReadString();
                agency.Name = agencyReader[1].ReadString();
                agency.Url  = agencyReader[2].ReadString();
                routes      = new List <string>();
                CompactFormatReader[] routeReader;
                while ((routeReader = agencyReader[3].Next()) != null)
                {
                    routes.Add(routeReader[0].ReadString());
                }
                result.Add(new Tuple <TransitAgency, string[]>(agency, routes.ToArray()));
            }
            return(result);
        }
Beispiel #3
0
 public static List<Tuple<TransitAgency, string[]>> DeformatAgencies(CompactFormatReader reader)
 {
     List<Tuple<TransitAgency, string[]>> result = new List<Tuple<TransitAgency, string[]>>();
     CompactFormatReader[] agencyReader;
     List<string> routes;
     while ((agencyReader = reader.Next()) != null)
     {
         TransitAgency agency = new TransitAgency();
         agency.ID = agencyReader[0].ReadString();
         agency.Name = agencyReader[1].ReadString();
         agency.Url = agencyReader[2].ReadString();
         routes = new List<string>();
         CompactFormatReader[] routeReader;
         while ((routeReader = agencyReader[3].Next()) != null)
         {
             routes.Add(routeReader[0].ReadString());
         }
         result.Add(new Tuple<TransitAgency, string[]>(agency, routes.ToArray()));
     }
     return result;
 }
Beispiel #4
0
 public static async Task SaveAgency(TransitAgency agency, string[] routes)
 {
     await EnsureFolders();
     await ModifyAgencyCache(delegate (List<Tuple<TransitAgency, string[]>> agencies)
     {
         agencies.RemoveAll(item => item.Item1 == agency);
         agencies.Add(new Tuple<TransitAgency, string[]>(agency, routes));
     });
 }
Beispiel #5
0
 public static async Task SaveAgency(TransitAgency agency, string[] routes)
 {
     await AccessAgencyCache(delegate (List<Tuple<TransitAgency, string[]>> agencies)
     {
         if (!agencies.Any(item => item.Item1 == agency))
         {
             agencies.Add(new Tuple<TransitAgency, string[]>(agency, routes));
             return true;
         }
         return false;
     });
 }