/// <summary> /// Initializes a new instance of the <see cref="MSGraphNotificationProvider"/> class. /// </summary> /// <param name="configuration">Instance of <see cref="IConfiguration"/>.</param> /// <param name="emailAccountManager">Instance of <see cref="IEmailAccountManager"/>.</param> /// <param name="logger">Instance of <see cref="ILogger"/>.</param> /// <param name="mSGraphSetting">Instance of <see cref="IEmailManager"/>.</param> /// <param name="pollyRetrySetting">Instance of <see cref="RetrySetting"/>.</param> /// <param name="tokenHelper">Instance of <see cref="ITokenHelper"/>.</param> /// <param name="msGraphProvider">Instance of <see cref="IMSGraphProvider"/>.</param> /// <param name="emailManager">Instance of <see cref="IEmailManager"/>..</param> public MSGraphNotificationProvider( IConfiguration configuration, IEmailAccountManager emailAccountManager, ILogger logger, IOptions <MSGraphSetting> mSGraphSetting, IOptions <RetrySetting> pollyRetrySetting, ITokenHelper tokenHelper, IMSGraphProvider msGraphProvider, IEmailManager emailManager) { this.configuration = configuration; this.applicationAccounts = JsonConvert.DeserializeObject <List <ApplicationAccounts> >(this.configuration?["ApplicationAccounts"]); this.emailAccountManager = emailAccountManager; this.logger = logger; _ = int.TryParse(this.configuration["RetrySetting:MaxRetries"], out this.maxTryCount); if (this.configuration?["MailSettings"] != null) { this.mailSettings = JsonConvert.DeserializeObject <List <MailSettings> >(this.configuration?["MailSettings"]); } this.mSGraphSetting = mSGraphSetting?.Value; this.pollyRetrySetting = pollyRetrySetting?.Value; this.jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(), NullValueHandling = NullValueHandling.Ignore, }; this.tokenHelper = tokenHelper; this.msGraphProvider = msGraphProvider; this.emailManager = emailManager; }
/// <summary> /// Initializes a new instance of the <see cref="EmailHandlerManager"/> class. /// </summary> /// <param name="configuration">An instance of <see cref="IConfiguration"/>.</param> /// <param name="mSGraphSetting">Graph settings <see cref="MSGraphSetting"/>.</param> /// <param name="cloudStorageClient">An instance of <see cref="ICloudStorageClient"/>.</param> /// <param name="logger">An instance of <see cref="ILogger"/>.</param> /// <param name="emailManager">An instance of <see cref="IEmailManager"/>.</param> public EmailHandlerManager( IConfiguration configuration, IOptions <MSGraphSetting> mSGraphSetting, ICloudStorageClient cloudStorageClient, ILogger logger, IEmailManager emailManager) { this.configuration = configuration; this.mSGraphSetting = mSGraphSetting?.Value; this.cloudStorageClient = cloudStorageClient; this.logger = logger; this.emailManager = emailManager; }
/// <summary> /// Initializes a new instance of the <see cref="EmailHandlerManager"/> class. /// </summary> /// <param name="configuration">An instance of <see cref="IConfiguration"/>.</param> /// <param name="mSGraphSetting">Graph settings <see cref="MSGraphSetting"/>.</param> /// <param name="cloudStorageClient">An instance of <see cref="ICloudStorageClient"/>.</param> /// <param name="logger">An instance of <see cref="ILogger"/>.</param> /// <param name="emailManager">An instance of <see cref="IEmailManager"/>.</param> public EmailHandlerManager( IConfiguration configuration, IOptions <MSGraphSetting> mSGraphSetting, ICloudStorageClient cloudStorageClient, ILogger logger, IEmailManager emailManager) { this.configuration = configuration; this.mSGraphSetting = mSGraphSetting?.Value; this.cloudStorageClient = cloudStorageClient; this.logger = logger; this.emailManager = emailManager; this.notificationQueue = this.configuration?[$"{ConfigConstants.StorageAccountConfigSectionKey}:{ConfigConstants.StorageAccNotificationQueueName}"]; }
/// <summary> /// Initializes a new instance of the <see cref="MSGraphProvider"/> class. /// </summary> /// <param name="mSGraphSetting">MS Graph Settings from configuration.</param> /// <param name="pollyRetrySetting">Polly Retry Settings.</param> /// <param name="logger">Instance of Logger.</param> /// <param name="httpClient">Http Client.</param> public MSGraphProvider(IOptions <MSGraphSetting> mSGraphSetting, IOptions <RetrySetting> pollyRetrySetting, ILogger logger, HttpClient httpClient) { this.jsonSerializerSettings = new JsonSerializerSettings { Converters = new List <JsonConverter> { new StringEnumConverter() }, ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(), NullValueHandling = NullValueHandling.Ignore, }; this.mSGraphSetting = mSGraphSetting?.Value; this.pollyRetrySetting = pollyRetrySetting?.Value; this.logger = logger; this.httpClient = httpClient; }
/// <summary> /// Initializes a new instance of the <see cref="TokenHelper"/> class. /// </summary> /// <param name="userTokenSetting">User token setting from configuration.</param> /// <param name="mSGraphSetting">MS Graph Settings from configuration.</param> /// <param name="logger">Instance of <see cref="ILogger"/>.</param> /// <param name="emailAccountManager">Instance of <see cref="IEmailAccountManager"/>.</param> public TokenHelper(IOptions <UserTokenSetting> userTokenSetting, IOptions <MSGraphSetting> mSGraphSetting, ILogger logger, IEmailAccountManager emailAccountManager) { if (userTokenSetting is null) { throw new System.ArgumentNullException(nameof(userTokenSetting)); } if (mSGraphSetting is null) { throw new System.ArgumentNullException(nameof(mSGraphSetting)); } this.userTokenSetting = userTokenSetting.Value; this.mSGraphSetting = mSGraphSetting.Value; this.logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); this.emailAccountManager = emailAccountManager; }
/// <summary> /// Initializes a new instance of the <see cref="MSGraphNotificationProvider"/> class. /// </summary> /// <param name="configuration">Instance of <see cref="IConfiguration"/>.</param> /// <param name="emailAccountManager">Instance of <see cref="IEmailAccountManager"/>.</param> /// <param name="logger">Instance of <see cref="ILogger"/>.</param> /// <param name="mSGraphSetting">Instance of <see cref="IEmailManager"/>.</param> /// <param name="tokenHelper">Instance of <see cref="ITokenHelper"/>.</param> /// <param name="msGraphProvider">Instance of <see cref="IMSGraphProvider"/>.</param> /// <param name="emailManager">Instance of <see cref="IEmailManager"/>..</param> public MSGraphNotificationProvider( IConfiguration configuration, IEmailAccountManager emailAccountManager, ILogger logger, IOptions <MSGraphSetting> mSGraphSetting, ITokenHelper tokenHelper, IMSGraphProvider msGraphProvider, IEmailManager emailManager) { this.configuration = configuration; this.applicationAccounts = JsonConvert.DeserializeObject <List <ApplicationAccounts> >(this.configuration?[ConfigConstants.ApplicationAccountsConfigSectionKey]); this.emailAccountManager = emailAccountManager; this.logger = logger; _ = int.TryParse(this.configuration[$"{ConfigConstants.RetrySettingConfigSectionKey}:{ConfigConstants.RetrySettingMaxRetryCountConfigKey}"], out this.maxTryCount); if (this.configuration?[ConfigConstants.MailSettingsConfigKey] != null) { this.mailSettings = JsonConvert.DeserializeObject <List <MailSettings> >(this.configuration?[ConfigConstants.MailSettingsConfigKey]); } this.mSGraphSetting = mSGraphSetting?.Value; this.tokenHelper = tokenHelper; this.msGraphProvider = msGraphProvider; this.emailManager = emailManager; }