title: How register Microsoft.Exchange.WebServices.Data.ExchangeService at IServiceCollection
body: <p>I implemented a <code>CalendarService</code> in my asp.net core project which provides functions to get data from an exchange server. For calling the exchange server I'm using the lib from NuGet <a href="https://www.nuget.org/packages/Microsoft.Exchange.WebServices.NETStandard" rel="nofollow noreferrer">https://www.nuget.org/packages/Microsoft.Exchange.WebServices.NETStandard</a></p>
  
  <p>At the moment I create the instance of <code>ExchangeService</code> inside the <code>CalendarService</code> class with credentials inside it. But I want register the <code>CalendarService</code> in the <code>Startup</code> class.</p>
  
  <pre><code>namespace API.Infrastructure.Services
  {
      class CalendarService : ICalendarService
      {
          private readonly ExchangeService _exchangeService;
  
          public CalendarService ()
          {
              _exchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
              _exchangeService.Credentials = new WebCredentials("username", "password", "domain");
              _exchangeService.Url = new Uri("https://xxx/Exchange.asmx")
          }
  
          public Task&lt;Termin&gt; GetEventsBasedOnSearchCritera(DateTime start, DateTime end)
          {
              /// ...
          }
      }
  }
  </code></pre>
  
  <p>Now I want register the <code>CalendarService</code> via <code>ConfigureServices(IServiceCollection services)</code> method from  <code>Startup.cs</code> class like the <code>GitHubService</code> with its <code>HttpClient</code> example at <a href="https://docs.microsoft.com/de-de/aspnet/core/fundamentals/http-requests?view=aspnetcore-2.2#typed-clients" rel="nofollow noreferrer">https://docs.microsoft.com/de-de/aspnet/core/fundamentals/http-requests?view=aspnetcore-2.2#typed-clients</a> but <code>IServiceCollection</code> doesn't provide a method to add an <code>ExchangeService</code>.</p>
  
  <p>Has someone any idea how can register the ExchangeService in the Startup class?</p>