/// <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="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="SMTPNotificationProvider"/> class. /// </summary> /// <param name="emailAccountManager"> IEmailAccountManager.</param> /// <param name="logger"> ILogger.</param> /// <param name="configuration"> IConfiguration.</param> /// <param name="emailManager"> IEmailManager.</param> public SMTPNotificationProvider( IEmailAccountManager emailAccountManager, ILogger logger, IConfiguration configuration, IEmailManager emailManager) { this.emailAccountManager = emailAccountManager; this.logger = logger; this.configuration = configuration; this.smtpSetting = this.configuration?.GetSection(ConfigConstants.SMTPSettingConfigSectionKey).Get <SMTPSetting>(); this.applicationAccounts = JsonConvert.DeserializeObject <List <ApplicationAccounts> >(this.configuration?[ConfigConstants.ApplicationAccountsConfigSectionKey]); _ = 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.emailManager = emailManager; }
/// <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; }