Skip to content

Commit 7f78309

Browse files
committed
Format C# code
1 parent f7aba90 commit 7f78309

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

text-counter-blazor/Program.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
var builder = WebApplication.CreateBuilder(args);
44

55
// Add services to the container.
6-
builder.Services.AddRazorComponents()
7-
.AddInteractiveServerComponents();
6+
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
87

98
var app = builder.Build();
109

@@ -21,7 +20,6 @@
2120
app.UseStaticFiles();
2221
app.UseAntiforgery();
2322

24-
app.MapRazorComponents<App>()
25-
.AddInteractiveServerRenderMode();
23+
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
2624

2725
app.Run();
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
Console.WriteLine("Type text, then press Ctrl+D to calculate the number of characters, words and lines.");
1+
Console.WriteLine(
2+
"Type text, then press Ctrl+D to calculate the number of characters, words and lines."
3+
);
24
string textContent = "";
35
while (true)
46
{
5-
string textInput = Console.ReadLine();//read text input in each line
6-
if (textInput == null | textInput == "")//if Ctrl+D is pressed or text input is empty
7+
string textInput = Console.ReadLine(); //read text input in each line
8+
if (textInput == null | textInput == "") //if Ctrl+D is pressed or text input is empty
79
{
8-
break;//end while loop
10+
break; //end while loop
911
}
10-
textContent += textInput + '\n';//add text content from entered text input for each line
12+
textContent += textInput + '\n'; //add text content from entered text input for each line
1113
}
12-
Console.WriteLine($"Characters: {textContent.Length.ToString("N0")}");//number of characters
13-
Console.WriteLine($"Words: {textContent.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}");//number of words
14-
Console.WriteLine($"Lines: {textContent.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}");//number of lines
14+
Console.WriteLine($"Characters: {textContent.Length.ToString("N0")}"); //number of characters
15+
Console.WriteLine(
16+
$"Words: {textContent.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}"
17+
); //number of words
18+
Console.WriteLine(
19+
$"Lines: {textContent.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}"
20+
); //number of lines

text-counter-razor/Pages/Error.cshtml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ public void OnGet()
2424
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
2525
}
2626
}
27-

text-counter-razor/Pages/Index.cshtml.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,5 @@ public IndexModel(ILogger<IndexModel> logger)
1212
_logger = logger;
1313
}
1414

15-
public void OnGet()
16-
{
17-
18-
}
15+
public void OnGet() { }
1916
}

text-counter-razor/Pages/TextCounter.cshtml.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
public class TextCounterModel : PageModel
55
{
66
[BindProperty]
7-
public string? textContent { get; set; }//text content string input from text box
8-
public int characters { get; set; }//number of characters
9-
public int words { get; set; }//number of words
10-
public int lines { get; set; }//number of lines
7+
public string? textContent { get; set; } //text content string input from text box
8+
public int characters { get; set; } //number of characters
9+
public int words { get; set; } //number of words
10+
public int lines { get; set; } //number of lines
11+
1112
public void OnPost()
1213
{
13-
textContent = Request.Form["textContent"];//get text box input
14-
characters = textContent?.Length ?? 0;//update number of characters, words and lines based on entered text
15-
words = textContent?.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length ?? 0;
14+
textContent = Request.Form["textContent"]; //get text box input
15+
characters = textContent?.Length ?? 0; //update number of characters, words and lines based on entered text
16+
words =
17+
textContent
18+
?.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
19+
.Length ?? 0;
1620
lines = textContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0;
1721
}
18-
}
22+
}

0 commit comments

Comments
 (0)