Pregunta

Estoy tratando de deserializar un archivo iCal y luego mapear la colección a un POCO personalizado.El problema es que no estoy seguro de dónde se almacenan las propiedades.

aquí es el método de deserialización

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;
    }
}

Luego, en mi servicio, estoy tratando de asignar las propiedades en mi POCO, pero no puedo encontrar las propiedades.

var url = string.Format(GoogleICalUrl, calendarID);
var feed = iCalUtility.Deserialize(url);

foreach(var e in feed)
{
    calendarModel.title = e.WhereTheHellAreThePropertiesKept;
}

¿Alguien sabe de la manera correcta de bucle a través del iCalendarCollection y obtener todas las propiedades?

Revisé el sitio web de los días, pero ha estado abajo todo el día.

¿Fue útil?

Solución

After some digging, it turns out that IICalendarCollection has a nested Event collection that needs to be parsed 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});
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top