Пример #1
0
        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));
            }
        }
Пример #2
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);
            }
        }
        protected override T StreamDeligate <T>(ValidYear year, ValidLunarMonth month, Func <Stream, T> method)
        {
            string path = Helpers.CombinePath(_basePath, year, month);

            return(StreamDeligate <T>(path, method));
        }
Пример #4
0
 public ILunarSolarCalendarMonth GetMonthData(ValidYear year, ValidLunarMonth month) => throw new NotImplementedException();
Пример #5
0
 protected abstract T StreamDeligate <T>(ValidYear year, ValidLunarMonth month, Func <Stream, T> method);
Пример #6
0
        static public Uri CombinePath(string baseUrl, ValidYear year, ValidLunarMonth month)
        {
            var path = $"{baseUrl}/{year}/{month}/index.json";

            return(new Uri(path));
        }
        protected override T StreamDeligate <T>(ValidYear year, ValidLunarMonth month, Func <Stream, T> method)
        {
            Uri uri = Helpers.CombinePath(_baseUrl, year, month);

            return(StreamDeligate <T>(uri, method));
        }
Пример #8
0
        static internal string CombinePath(string basePath, ValidYear year, ValidLunarMonth month)
        {
            var path = Path.Combine(basePath, (string)year, (string)month, "index.json");

            return(path);
        }