Пример #1
0
        public override void Parse(XElement element)
        {
            var pairs = element.Descendants("series_work");

            if (pairs.Any())
            {
                var dict = new Dictionary <long, SeriesResource>();

                foreach (var pair in pairs)
                {
                    var series = new SeriesResource();
                    series.Parse(pair.Element("series"));

                    if (!dict.TryGetValue(series.Id, out var cached))
                    {
                        dict[series.Id] = series;
                        cached          = series;
                    }

                    var work = new WorkResource();
                    work.Parse(pair.Element("work"));
                    work.SetSeriesInfo(pair);

                    cached.Works.Add(work);
                }

                List = dict.Values.ToList();
            }
            else
            {
                List = new List <SeriesResource>();
            }
        }
Пример #2
0
        public override void Parse(XElement element)
        {
            Series = new SeriesResource();
            Series.Parse(element);

            Series.Works = element.ParseChildren <WorkResource>("series_works", "series_work");
        }
Пример #3
0
        private static Series MapSeries(SeriesResource resource)
        {
            var series = new Series
            {
                ForeignSeriesId  = resource.Id.ToString(),
                Title            = resource.Title,
                Description      = resource.Description,
                Numbered         = resource.IsNumbered,
                WorkCount        = resource.SeriesWorksCount,
                PrimaryWorkCount = resource.PrimaryWorksCount
            };

            return(series);
        }