private static async Task <CalendarProperties> GetCalendarProperties(CalDavDataAccess calDavDataAccess) { return ((await calDavDataAccess.IsCalendarAccessSupported() ? CalendarProperties.CalendarAccessSupported : CalendarProperties.None) | (await calDavDataAccess.IsWriteable() ? CalendarProperties.IsWriteable : CalendarProperties.None) | (await calDavDataAccess.DoesSupportCalendarQuery() ? CalendarProperties.SupportsCalendarQuery : CalendarProperties.None)); }
private async Task <bool> TestCalendar(CalDavDataAccess calDavDataAccess, StringBuilder errorMessageBuilder) { bool hasError = false; if (!await calDavDataAccess.IsCalendarAccessSupported()) { errorMessageBuilder.AppendLine("- The specified Url does not support calendar access."); hasError = true; } if (!await calDavDataAccess.IsWriteable()) { errorMessageBuilder.AppendLine("- The specified Url is a read-only calendar."); hasError = true; } if (!await calDavDataAccess.DoesSupportCalendarQuery()) { errorMessageBuilder.AppendLine("- The specified Url does not support Calendar Queries."); hasError = true; } if (_folderType != OlItemType.olAppointmentItem && _folderType != OlItemType.olTaskItem) { errorMessageBuilder.AppendLine("- The outlook folder is not a calendar or task folder, or there is no folder selected."); hasError = true; } return(hasError); }
public static async Task <TestResult> TestConnection(Uri url, IWebDavClient webDavClient, ResourceType supposedRessourceType) { var calDavDataAccess = new CalDavDataAccess(url, webDavClient); var cardDavDataAccess = new CardDavDataAccess(url, webDavClient); TestResult result; switch (supposedRessourceType) { case ResourceType.None: var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); result = new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None); break; case ResourceType.Calendar: result = new TestResult( supposedRessourceType, CalendarProperties.CalendarAccessSupported | (await calDavDataAccess.IsWriteable() ? CalendarProperties.IsWriteable : CalendarProperties.None) | (await calDavDataAccess.DoesSupportCalendarQuery() ? CalendarProperties.SupportsCalendarQuery : CalendarProperties.None), AddressBookProperties.None); break; case ResourceType.AddressBook: result = new TestResult( supposedRessourceType, CalendarProperties.None, AddressBookProperties.AddressBookAccessSupported | (await cardDavDataAccess.IsWriteable() ? AddressBookProperties.IsWriteable : AddressBookProperties.None)); break; default: throw new ArgumentOutOfRangeException("supposedRessourceType"); } return(result); }