Skip to content

Commit

Permalink
Merge pull request #55 from 77/master
Browse files Browse the repository at this point in the history
Fix crash that occurs if you click detect settings when form is empty.
  • Loading branch information
akankshagaur committed Jul 7, 2018
2 parents 3eeeb1a + 514dd32 commit 4a15fe2
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -50,7 +50,7 @@ public ExchangeWebCalendarService(ApplicationLogger applicationLogger)
public ExchangeService GetExchangeService(ExchangeServerSettings exchangeServerSettings)
{
ExchangeVersion exchangeVersion;
var isValidVersion = Enum.TryParse(exchangeServerSettings.ExchangeVersion, true, out exchangeVersion);
var isValidVersion = Enum.TryParse(exchangeServerSettings?.ExchangeVersion, true, out exchangeVersion);
if (isValidVersion)
{
var service = new ExchangeService(exchangeVersion)
Expand Down Expand Up @@ -108,12 +108,15 @@ public ExchangeService GetExchangeService(ExchangeServerSettings exchangeServerS

// Call FindFolders to retrieve the folder hierarchy, starting with the MsgFolderRoot folder.
// This method call results in a FindFolder call to EWS.
var findFolderResults = service.FindFolders(WellKnownFolderName.MsgFolderRoot, view);
var findFolderResults = service?.FindFolders(WellKnownFolderName.MsgFolderRoot, view);

var ewsCalendars = new List<EWSCalendar>();
foreach (var searchFolder in findFolderResults.Folders)
if (findFolderResults != null)
{
GetCalendars(searchFolder, ewsCalendars, view);
foreach (var searchFolder in findFolderResults.Folders)
{
GetCalendars(searchFolder, ewsCalendars, view);
}
}
return ewsCalendars;
}
Expand Down

0 comments on commit 4a15fe2

Please sign in to comment.