From 82f8b3bf7e66de5cb3de53369b5a263f3d82c084 Mon Sep 17 00:00:00 2001 From: Aaron Lord Date: Tue, 4 Apr 2017 16:28:46 -0700 Subject: [PATCH] Cleanup --- Devlord.Utilities.sln.DotSettings | 10 ++--- src/Devlord.Utilities/Crypt.cs | 14 +++--- .../Devlord.Utilities.csproj | 3 ++ src/Devlord.Utilities/Logger.cs | 1 - src/Devlord.Utilities/Mailbot.cs | 43 ++++++++++--------- src/Devlord.Utilities/Settings.cs | 31 ++++++------- .../DRMapperTimeTests.cs | 1 - 7 files changed, 48 insertions(+), 55 deletions(-) diff --git a/Devlord.Utilities.sln.DotSettings b/Devlord.Utilities.sln.DotSettings index 72f6a03..3056253 100644 --- a/Devlord.Utilities.sln.DotSettings +++ b/Devlord.Utilities.sln.DotSettings @@ -1,14 +1,12 @@  -------------------------------------------------------------------------------------------------------------------- <copyright file="$FILENAME$" company="Lord Design"> - © Lord Design + © $CURRENT_YEAR$ Lord Design </copyright> -<license type="GPL"> - You may use freely and commercially without modification; you can modify if result - is also free. +<license type="GPL-3.0"> + You may use freely and commercially without modification; if you make changes, please share back to the + community. </license> -<summary> -</summary> <author>$USER_NAME$</author> -------------------------------------------------------------------------------------------------------------------- diff --git a/src/Devlord.Utilities/Crypt.cs b/src/Devlord.Utilities/Crypt.cs index 4287032..56e92cc 100644 --- a/src/Devlord.Utilities/Crypt.cs +++ b/src/Devlord.Utilities/Crypt.cs @@ -1,12 +1,12 @@ // -------------------------------------------------------------------------------------------------------------------- -// -// +// +// © 2017 Lord Design // -// 10/22/2012 3:42 PM -// aaron@lorddesign.net -// -// TODO: Update summary. -// +// +// You may use freely and commercially without modification; if you make changes, please share back to the +// community. +// +// Aaron Lord // -------------------------------------------------------------------------------------------------------------------- using System; diff --git a/src/Devlord.Utilities/Devlord.Utilities.csproj b/src/Devlord.Utilities/Devlord.Utilities.csproj index ffca243..d57774c 100644 --- a/src/Devlord.Utilities/Devlord.Utilities.csproj +++ b/src/Devlord.Utilities/Devlord.Utilities.csproj @@ -28,6 +28,9 @@ --> + + bin\Debug\Devlord.Utilities.xml + diff --git a/src/Devlord.Utilities/Logger.cs b/src/Devlord.Utilities/Logger.cs index 27e073b..eedfadc 100644 --- a/src/Devlord.Utilities/Logger.cs +++ b/src/Devlord.Utilities/Logger.cs @@ -22,7 +22,6 @@ public partial class Logger protected Logger() { } - } #if !NETSTANDARD1_3 diff --git a/src/Devlord.Utilities/Mailbot.cs b/src/Devlord.Utilities/Mailbot.cs index f5264f8..c0708c4 100644 --- a/src/Devlord.Utilities/Mailbot.cs +++ b/src/Devlord.Utilities/Mailbot.cs @@ -11,7 +11,6 @@ // -------------------------------------------------------------------------------------------------------------------- using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; namespace Devlord.Utilities @@ -22,24 +21,12 @@ namespace Devlord.Utilities /// public partial class Mailbot { - // Per minute 180, Per hour 3600, Per day 10,000 - - public async Task QueueMail(Botmail message) - { - await SendMail(message); - } - - #region Fields - private readonly Crypt _crypt = new Crypt(); - - /// - /// The throttles. - /// - private Throttles _throttles = new Throttles(); + private static readonly object DictionaryLock = new object(); - #endregion + private static readonly Dictionary Instances = new Dictionary(); #region Constructors and Destructors + /// /// Private constructor to enforce use of singleton. /// @@ -58,7 +45,21 @@ private Mailbot() #endregion - private static readonly object DictionaryLock = new object(); + #region Public Properties + + /// + /// Gets the SMTP server. + /// + public string SmtpServer { get; private set; } + + #endregion + + // Per minute 180, Per hour 3600, Per day 10,000 + + public async Task QueueMail(Botmail message) + { + await SendMail(message); + } /// /// Gets the instance. @@ -85,14 +86,14 @@ public static Mailbot GetInstance(string smtpServer) } } - private static readonly Dictionary Instances = new Dictionary(); + #region Fields - #region Public Properties + private readonly Crypt _crypt = new Crypt(); /// - /// Gets the SMTP server. + /// The throttles. /// - public string SmtpServer { get; private set; } + private Throttles _throttles = new Throttles(); #endregion } diff --git a/src/Devlord.Utilities/Settings.cs b/src/Devlord.Utilities/Settings.cs index ccc5c21..aaa8d66 100644 --- a/src/Devlord.Utilities/Settings.cs +++ b/src/Devlord.Utilities/Settings.cs @@ -12,7 +12,6 @@ // -------------------------------------------------------------------------------------------------------------------- using System; -using System.Collections.Generic; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; @@ -33,16 +32,6 @@ private Settings() public string SmtpLogin => GetValue("Devlord.Utilities:SmtpLogin"); public string SmtpPassword => GetValue("Devlord.Utilities:SmtpPassword"); - public T GetValue(string propertyName) - { - string value = _configuration[propertyName]; - if (value != null) - { - return JsonConvert.DeserializeObject(value); - } - throw new SettingNotFoundException(propertyName); - } - private static IConfiguration GetConfig() { var builder = new ConfigurationBuilder() @@ -52,16 +41,20 @@ private static IConfiguration GetConfig() .SetBasePath(AppContext.BaseDirectory) #endif .AddJsonFile("devlord.utilities.json", - optional: true, - reloadOnChange: true); + true, + true); return builder.Build(); } + public T GetValue(string propertyName) + { + var value = _configuration[propertyName]; + if (value != null) + { + return JsonConvert.DeserializeObject(value); + } + throw new SettingNotFoundException(propertyName); + } } - - public class SettingNotFoundException : KeyNotFoundException - { - public SettingNotFoundException(string setting) : base($"{nameof(SettingNotFoundException)}: {setting}") { } - } -} +} \ No newline at end of file diff --git a/test/Devlord.Utilities.Tests/DRMapperTimeTests.cs b/test/Devlord.Utilities.Tests/DRMapperTimeTests.cs index 9ede30c..17ad97a 100644 --- a/test/Devlord.Utilities.Tests/DRMapperTimeTests.cs +++ b/test/Devlord.Utilities.Tests/DRMapperTimeTests.cs @@ -79,7 +79,6 @@ public void TestDRMapperSingleRow() { Stopwatch stopwatch; TestData result; - List results; var inMemoryData = Builder.CreateListOfSize(1).Build(); using (var dataReader = ObjectReader.Create(inMemoryData)) {