Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
ref - Cleaned things up
Browse files Browse the repository at this point in the history
We've cleaned things up.

---

In preparation for the release, we've cleaned things up.

---

Type: ref
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Aug 12, 2023
1 parent 0b10fdb commit 1492cdb
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions Namer/NameGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http;
Expand Down Expand Up @@ -55,21 +54,9 @@ public static async Task PopulateNamesAsync()
try
{
if (Names.Length == 0)
{
HttpResponseMessage Response = await NameClient.GetAsync(nameAddress);
Response.EnsureSuccessStatusCode();
Stream NamesStream = await Response.Content.ReadAsStreamAsync();
string NamesString = new StreamReader(NamesStream).ReadToEnd();
Names = NamesString.SplitNewLines();
}
Names = await PopulateInternalAsync(nameAddress);
if (Surnames.Length == 0)
{
HttpResponseMessage Response = await NameClient.GetAsync(surnameAddress);
Response.EnsureSuccessStatusCode();
Stream SurnamesStream = await Response.Content.ReadAsStreamAsync();
string SurnamesString = new StreamReader(SurnamesStream).ReadToEnd();
Surnames = SurnamesString.SplitNewLines();
}
Surnames = await PopulateInternalAsync(surnameAddress);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -338,6 +325,15 @@ internal static string[] GenerateNameArray(int Count, string NamePrefix, string
return namesList.ToArray();
}

internal static async Task<string[]> PopulateInternalAsync(string nameLink)
{
HttpResponseMessage Response = await NameClient.GetAsync(nameLink);
Response.EnsureSuccessStatusCode();
Stream SurnamesStream = await Response.Content.ReadAsStreamAsync();
string SurnamesString = new StreamReader(SurnamesStream).ReadToEnd();
return SurnamesString.SplitNewLines();
}

/// <summary>
/// Makes a string array with new line as delimiter
/// </summary>
Expand Down

0 comments on commit 1492cdb

Please sign in to comment.