msgraph-sdk-dotnet
msgraph-sdk-dotnet copied to clipboard
Syntax looks a bit odd in C#
While using this library I've come across some really weird syntax. For instance, if I were to retrieve my calendar permissions I'd do the following:
`await graphServiceClient.Users["[email protected]"].Calendar.Request().GetAsync();`
In C#, square brackets are used as indexer operators, so if I were to see the code above, I'd assume that
`graphServiceClient.Users`
is a collection like a dictionary/hashtable where "[email protected]" is a key. It also implies that the value returned from the dictionary has the properties "Calendar" which in turn which in turn has the method "Request" which returns an object which has "GetAsync".
In reality,
`graphServiceClient.Users`
is not a collection at all, is not being indexed, in fact I have never come across this before. What is being accessed? Why not have something like:
`await graphServiceClient.Users.GetCalendarAsync("[email protected]");`
You can see exactly what it's doing at a glance