Deserialize iCal using DDay.iCal cannot find properties

I try to deserialize the iCal file and then map the collection to custom POCO. The problem is that I'm not sure where the properties are stored.

Here's the deserialization method

public static IICalendarCollection Deserialize(String iCalUri) { var wc = new WebClient(); var result = wc.DownloadString(iCalUri); using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(result))) { var serializer = new iCalendarSerializer(); var collection = (iCalendarCollection)serializer.Deserialize(memoryStream, Encoding.UTF8); return collection; } } 

Then in my service I try to map properties to my POCO, but I can not find the properties.

 var url = string.Format(GoogleICalUrl, calendarID); var feed = iCalUtility.Deserialize(url); foreach(var e in feed) { calendarModel.title = e.WhereTheHellAreThePropertiesKept; } 

Does anyone know the correct path to loop through iCalendarCollection and get all the properties?

I checked the DDay website, but it did not work all day.

+4
source share
1 answer

After some digging, it turns out that the IICalendarCollection has a nested collection of events that should be analyzed as follows.

 var url = string.Format(GoogleICalUrl, calendarID); var feed = iCalUtility.Deserialize(url); foreach (var ev in feed.SelectMany(e => e.Events)) { calendarModel.Add(new CalendarModel {description = ev.Description, title = ev.Summary}); } 
+2
source

Source: https://habr.com/ru/post/1400517/


All Articles