Skip to content

Instantly share code, notes, and snippets.

View ArisAgnew's full-sized avatar
:electron:
You gotta do what you gotta do

Εὐγενής Αναγνωστόπουλος ArisAgnew

:electron:
You gotta do what you gotta do
  • Europe
View GitHub Profile
@ArisAgnew
ArisAgnew / Table-DrivenApproach.cs
Created June 20, 2021 20:01
Refactoring If-Else to Table-Driven Approach
//If-Else Approach
public static class ParserFactory
{
public static IFileParser Create(string filename)
{
var extension = Path.GetExtension(fileName);
if (extension == ".json")
{
return new JsonParser();
@ArisAgnew
ArisAgnew / Program.cs
Created November 27, 2021 13:27 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@ArisAgnew
ArisAgnew / WriteAsync.cs
Created February 12, 2022 11:57
The code snippet is a gauge of writing a piece of information to a file in an asynchronous way
Task.Run(ProcessWriteAsync); // main function call
async Task ProcessWriteAsync()
{
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
string subPath = @"logs\";
string fileName = $@"chatlogs.txt";
DirectoryInfo directoryInfo = new(baseDirectory);