private Calendar(CalDAVClient client) { _client = client; _calendar = new Ical.Net.Calendar(); _events = new List <Event>(); }
internal static async Task <Calendar> Deserialize(Resource resource, string uri, CalDAVClient client) { var calendar = new Calendar(client) { Uri = uri }; foreach (var property in resource.Properties) { switch (property.Key.LocalName) { case "displayname": calendar.DisplayName = property.Value; break; case "owner": calendar.Owner = property.Value.Contains("href") ? _hrefRegex.Replace(property.Value, "") : property.Value; break; case "getetag": calendar.ETag = property.Value; break; case "getlastmodified": calendar.LastModified = DateTime.Parse(property.Value); break; case "sync-token": calendar.SyncToken = property.Value; break; case "calendar-color": calendar.Color = property.Value; break; case "calendar-description": calendar.Description = property.Value; break; } } calendar.Uid = uri .Replace(calendar.Owner, "") .Replace("/", ""); // fetch events var events = await calendar.GetEventsAsync().ConfigureAwait(false); calendar._events = events.ToList(); return(calendar); }