Exemple #1
0
 public IList <DateTime> GetYear(ValidYear year)
 {
     return(StreamDeligate <IList <DateTime> >(
                year,
                Deserialize <List <DateTime> >
                ));
 }
Exemple #2
0
 public IList <ILunarSolarCalendarMonthDetailed> GetYearDataDetailed(ValidYear year)
 {
     return(StreamDeligate <IList <ILunarSolarCalendarMonthDetailed> >(
                year,
                DeserializeList <LunarSolarCalendarMonthDetailed, ILunarSolarCalendarMonthDetailed>
                ));
 }
Exemple #3
0
 public IList <ILunarSolarCalendarMonth> GetYearData(ValidYear year)
 {
     return(StreamDeligate <IList <ILunarSolarCalendarMonth> >(
                year,
                DeserializeList <LunarSolarCalendarMonth, ILunarSolarCalendarMonth>
                ));
 }
        protected override T StreamDeligate <T>(ValidYear year, Func <Stream, T> method)
        {
            string path = Helpers.CombinePath(_basePath, year);

            using (Stream s = File.OpenRead(path)){
                return(method(s));
            }
        }
Exemple #5
0
        protected override T StreamDeligate <T>(ValidYear year, Func <Stream, T> method)
        {
            Uri uri = Helpers.CombinePath(_baseUrl, year);

            using (Stream s = _client.GetStreamAsync(uri).Result){
                return(method(s));
            }
        }
        static internal T StreamHandler <T>(string basePath, ValidYear year, ValidLunarMonth month, Func <ValidYear, ValidLunarMonth, Stream, T> method)
        {
            string path = Helpers.CombinePath(basePath, year, month);

            using (Stream s = File.OpenRead(path))
            {
                return(method(year, month, s));
            }
        }
Exemple #7
0
        public ILunarSolarCalendarMonthDetailed GetMonthDataDetailed(ValidYear year, ValidLunarMonth month)
        {
            try
            {
                return(StreamDeligate <ILunarSolarCalendarMonthDetailed>(
                           year,
                           month,
                           Deserialize <LunarSolarCalendarMonthDetailed>
                           ));
            }
            catch (Exception e) when(ExpectedExceptionPredicate(e))
            {
                var monthsInYear = GetYear(year).Count();

                throw new SolarLunarName.SharedTypes.Exceptions.MonthDoesNotExistException(year, month, monthsInYear);
            }
        }
Exemple #8
0
 public IList <ILunarSolarCalendarMonth> GetYearData(ValidYear year)
 {
     return(new List <ILunarSolarCalendarMonth> {
         new LunarSolarCalendarMonth(19, new DateTime(1700, 1, 1)),
         new LunarSolarCalendarMonth(29, new DateTime(1700, 01, 20)),
         new LunarSolarCalendarMonth(30, new DateTime(1700, 02, 18)),
         new LunarSolarCalendarMonth(30, new DateTime(1700, 03, 20)),
         new LunarSolarCalendarMonth(29, new DateTime(1700, 04, 19)),
         new LunarSolarCalendarMonth(30, new DateTime(1700, 05, 18)),
         new LunarSolarCalendarMonth(29, new DateTime(1700, 06, 17)),
         new LunarSolarCalendarMonth(29, new DateTime(1700, 07, 16)),
         new LunarSolarCalendarMonth(30, new DateTime(1700, 08, 14)),
         new LunarSolarCalendarMonth(29, new DateTime(1700, 09, 13)),
         new LunarSolarCalendarMonth(29, new DateTime(1700, 10, 12)),
         new LunarSolarCalendarMonth(30, new DateTime(1700, 11, 10)),
         new LunarSolarCalendarMonth(22, new DateTime(1700, 12, 10))
     });
 }
        static internal string CombinePath(string basePath, ValidYear year)
        {
            var path = Path.Combine(basePath, (string)year, "index.json");

            return(path);
        }
        protected override T StreamDeligate <T>(ValidYear year, Func <Stream, T> method)
        {
            string path = Helpers.CombinePath(_basePath, year);

            return(StreamDeligate <T>(path, method));
        }
Exemple #11
0
 public IList <DateTime> GetYear(ValidYear year) => throw new NotImplementedException();
Exemple #12
0
 public ILunarSolarCalendarMonth GetMonthData(ValidYear year, ValidLunarMonth month) => throw new NotImplementedException();
        protected override T StreamDeligate <T>(ValidYear year, Func <Stream, T> method)
        {
            Uri uri = Helpers.CombinePath(_baseUrl, year);

            return(StreamDeligate <T>(uri, method));
        }
Exemple #14
0
 public IList <DateTime> GetYear(ValidYear year)
 {
     return(GetYearData(year)
            .Select(x => x.FirstDay)
            .ToList());
 }
Exemple #15
0
 protected override abstract T StreamDeligate <T>(ValidYear year, Func <Stream, T> method);
Exemple #16
0
 protected abstract T StreamDeligate <T>(ValidYear year, ValidLunarMonth month, Func <Stream, T> method);
Exemple #17
0
        static public Uri CombinePath(string baseUrl, ValidYear year)
        {
            var path = $"{baseUrl}/{year}/index.json";

            return(new Uri(path));
        }