A useful class library for universal utilities like encryption, sending emails, and consuming RESTful APIs.
Master | Develop | NuGet |
---|---|---|
To install Devlord.Utilities, run the following command in the Package Manager Console:
PM> Install-Package Devlord.Utilities
Or from the command-line:
dotnet add package Devlord.Utilities
- .NET Core compatibility
- System.Threading.Timers service clocks
- Email throttling to help you avoid being suspended by your ISP
- Generic HTTP API wrappers
- Two-way AES encryption
- "Micro-ORM" DataReader mapper for when using a full-featured ORM would be overkill
More details below, but for even more details, see the project wiki.
We've provided 3 types of timers for back-end services to execute operations
- At a certain time
- At a certain regular interval
- Continuously, repeating an action as soon as the previous action is complete
The ApiCall
class wraps the .NET HttpClient, and returns a deserialized object using Generics. It also features a Dictionary
for query parameter input. The WebApiCall
subclass will build your endpoint for ASP.NET MVC Web API based on the supplied
controller, action, and id as input parameters.
POCO classes for accessing the Google Maps distance API.
Usage with a custom JSON contract resolver that converts the Google JSON property names to POCO object properties.
const string BaseUri = "https://maps.googleapis.com/maps/api/distancematrix/json";
using (IApiCall client = new ApiCall(BaseUri,
new JsonSerializerSettings { ContractResolver = new UnderscoreContractResolver() }))
{
client.QueryParams.Add("sensor", "false");
client.QueryParams.Add("origins", "95969");
client.QueryParams.Add("destinations", "95928");
IApiResult<dynamic> result = client.Execute<DistanceResults>();
}
A handy generic DataManager abstract base class for your business layer that serves to enforce a CRUD contract between your business entities and your data layer. Useful for pagination as well.
A multithreaded SMTP queued mail sender, has a configurable throttle for mail frequency sent by a single account.
Configuration
{
"Devlord.Utilities": {
"GoogleMapsApiKey": "",
"MailSettings": [
{
"Name": "Gmail",
"SmtpServer": "mail.google.com",
"SmtpPort": 587,
"SmtpPassword": "",
"MaxPerMinute": 500,
"MaxPerHour": 500,
"MaxPerDay": 500
}
]
}
}
Bidirectional encryption methods useful for storing credit cards or encrypting passwords or API keys to save in a project's configuration files. (Not recommend for use with user's site credentials as those should use one-way encryption.)
Allows mapping of an IDataReader
to POCO classes using reflection. It's faster than you might expect.
var query = from a in context.Addresses where a.IsActive select a;
var results = query.GetPage(pageNumber, pageSize);
Yes, please!
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Contact lorddev on GitHub or @[email protected] on Mastodon.