-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit test added, toolbox build started with numerous utilities, exten…
…sions, and other useful tools.
- Loading branch information
1 parent
85f4be5
commit 0a85da4
Showing
38 changed files
with
2,821 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ArcherCore\ArcherCore.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using ArcherCore.Http; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Net.Http.Headers; | ||
using static ArcherCore.APIs.APIUtilities; | ||
|
||
internal class Program | ||
{ | ||
private static async Task Main(string[] args) | ||
{ | ||
await ArcherCore.Archer.SetupHttpClientFactory(); | ||
|
||
//var _httpClientFactory = HttpVariables.HttpClientFactory; | ||
//using(var client = _httpClientFactory.CreateClient()) | ||
//{ | ||
// var productValue = new ProductInfoHeaderValue("RBX-Version-Check", "1.0"); | ||
|
||
// client.DefaultRequestHeaders.UserAgent.Add(productValue); | ||
// var httpResponse = await client.GetAsync("https://api.github.com/repos/ReserveBlockIO/ReserveBlock-Core/releases/latest"); | ||
// var responseString = await httpResponse.Content.ReadAsStringAsync(); | ||
// var release = JsonConvert.DeserializeObject<Release>(responseString.ToString()); | ||
//} | ||
|
||
while (true) | ||
{ | ||
Console.Write("» "); | ||
var input = Console.ReadLine(); | ||
var isUpper = ArcherCore.Strings.StringUtilities.StartsWithUpper(input); | ||
var isLower = ArcherCore.Strings.StringUtilities.StartsWithLower(input); | ||
var upperResult = isUpper ? "Yes" : "No"; | ||
var lowerResult = isLower ? "Yes" : "No"; | ||
Console.WriteLine($"Is Upper? {upperResult}"); | ||
Console.WriteLine($"Is Lower? {lowerResult}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ArcherCore.APIs | ||
{ | ||
public static class APIUtilities | ||
{ | ||
//"https://api.github.com/repos/ReserveBlockIO/ReserveBlock-Core/releases/latest" | ||
public static async Task<Release?> GetLatestGithubRelease(string url) | ||
{ | ||
try | ||
{ | ||
HttpClient client = new HttpClient(); | ||
var productValue = new ProductInfoHeaderValue("RBX-Version-Check", "1.0"); | ||
|
||
client.DefaultRequestHeaders.UserAgent.Add(productValue); | ||
var httpResponse = await client.GetAsync(url); | ||
var responseString = await httpResponse.Content.ReadAsStringAsync(); | ||
var release = JsonConvert.DeserializeObject<Release>(responseString.ToString()); | ||
|
||
return release; | ||
} | ||
catch { return null; } | ||
|
||
} | ||
public class Release | ||
{ | ||
public string url { get; set; } | ||
|
||
public string html_url { get; set; } | ||
|
||
public string assets_url { get; set; } | ||
|
||
public string upload_url { get; set; } | ||
|
||
public int id { get; set; } | ||
public string node_id { get; set; } | ||
|
||
public string tag_name { get; set; } | ||
|
||
public string target_commitish { get; set; } | ||
|
||
public string name { get; set; } | ||
|
||
public string body { get; set; } | ||
|
||
public bool draft { get; set; } | ||
|
||
public bool prerelease { get; set; } | ||
|
||
public DateTimeOffset created_at { get; set; } | ||
|
||
public DateTimeOffset? published_at { get; set; } | ||
|
||
public Author author { get; set; } | ||
|
||
public string tarball_url { get; set; } | ||
|
||
public string zipball_url { get; set; } | ||
|
||
public IReadOnlyList<ReleaseAsset> assets { get; set; } | ||
} | ||
|
||
public class ReleaseAsset | ||
{ | ||
|
||
public string url { get; set; } | ||
|
||
public int id { get; set; } | ||
public string node_id { get; set; } | ||
|
||
public string name { get; set; } | ||
|
||
public string label { get; set; } | ||
|
||
public string State { get; set; } | ||
|
||
public string content_type { get; set; } | ||
|
||
public int size { get; set; } | ||
|
||
public int download_count { get; set; } | ||
|
||
public DateTimeOffset created_at { get; set; } | ||
|
||
public DateTimeOffset updated_at { get; set; } | ||
|
||
public string browser_download_url { get; set; } | ||
|
||
public Author uploader { get; set; } | ||
|
||
} | ||
|
||
public class Author | ||
{ | ||
public string login { get; set; } | ||
|
||
public int Id { get; set; } | ||
|
||
public string node_id { get; set; } | ||
|
||
public string avatar_url { get; set; } | ||
|
||
public string url { get; set; } | ||
|
||
public string html_url { get; set; } | ||
|
||
public string followers_url { get; set; } | ||
|
||
public string following_url { get; set; } | ||
|
||
public string gists_url { get; set; } | ||
|
||
public string starred_url { get; set; } | ||
|
||
public string subscriptions_url { get; set; } | ||
|
||
public string organizations_url { get; set; } | ||
|
||
public string repos_url { get; set; } | ||
|
||
public string events_url { get; set; } | ||
|
||
public string received_events_url { get; set; } | ||
|
||
public string type { get; set; } | ||
|
||
public bool site_admin { get; set; } | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using ArcherCore.Email; | ||
using ArcherCore.Http; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using System.Globalization; | ||
using System.Net.Mail; | ||
|
||
namespace ArcherCore | ||
{ | ||
public static class Archer | ||
{ | ||
public static async Task SetupEmail(string host, int port, SmtpDeliveryMethod deliveryMethod, bool enableSsl = true, bool useDefaultCreds = false) | ||
{ | ||
EmailVariables.Host = host; | ||
EmailVariables.Port = port; | ||
EmailVariables.SmtpDeliveryMethod = deliveryMethod; | ||
EmailVariables.EnableSSL = enableSsl; | ||
EmailVariables.UseDefaultCredentials = useDefaultCreds; | ||
} | ||
|
||
public static async Task SetupHttpClientFactory(bool enableLogging = false, string[]? args = null) | ||
{ | ||
var httpClientBuilder = Host.CreateDefaultBuilder(args) | ||
.ConfigureServices(services => | ||
{ | ||
services.AddHttpClient(); | ||
services.AddTransient<HttpService>(); | ||
}) | ||
.ConfigureLogging(enableLogging ? loggingBuilder => loggingBuilder.AddSimpleConsole() : loggingBuilder => loggingBuilder.ClearProviders()) | ||
.Build(); | ||
|
||
await httpClientBuilder.StartAsync(); | ||
HttpVariables.HttpClientFactory = httpClientBuilder.Services.GetRequiredService<HttpService>().HttpClientFactory(); | ||
} | ||
|
||
public static async Task ForceUSCulture() | ||
{ | ||
var culture = CultureInfo.GetCultureInfo("en-US"); | ||
if (Thread.CurrentThread.CurrentCulture.Name != "en-US") | ||
{ | ||
CultureInfo.DefaultThreadCurrentCulture = culture; | ||
CultureInfo.DefaultThreadCurrentUICulture = culture; | ||
|
||
Thread.CurrentThread.CurrentCulture = culture; | ||
Thread.CurrentThread.CurrentUICulture = culture; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace ArcherCore.EllipticCurve | ||
{ | ||
public static class Base64 | ||
{ | ||
public static byte[] decode(string base64String) | ||
{ | ||
return Convert.FromBase64String(base64String); | ||
} | ||
|
||
public static string encode(byte[] bytes) | ||
{ | ||
return Convert.ToBase64String(bytes); | ||
} | ||
} | ||
} |
Oops, something went wrong.