So this is a pretty neat project I intermittently work on. This is a discord bot using the Discord.NET wrapper from RogueException. It makes use of the onion architecture and I tend to think while indeed a small project at this time, is the best showcase of my growth as a programmer and knowledge of OOP.
One really neat feature I love to draw attention to is the command system. I sometimes get called out for overengineering the solution, but I highly disagree. One thing I've really bought into is the idea of future-proofing your application. Most discord bot command systems use hard-coded strings somewhere to dictate what command is being parsed. Something many programmers do is use a switch statement. This is fine, however I understood that as the needs for the discord server I administrate grow so will the scope of this project. I needed a more... automated solution. The idea came to me to use reflection for this so I could create/delete classes that were prefixed with the command and compiled at run time in order to be parsed and executed. Long night made short, I evolved from using Activator to compiling lambda expressions which displayed a HUGE performance increase (almost near raw hardcoded performance). This allowed me to have a solution where I don't need to manually maintain a switch block or refactor strings in the event commands change.
Hope y'all dig it!
Blog Writeup: https://reiko.tech/Blog/View/8
A nice read about microservices. Even though they mention .NET a lot, the content is still pretty relevant with other languages.
Also, I uploaded the e-book as attachment as I am not sure about file storage on the server, I will provide you guys with a direct link to the download. (Which is also available on the overview page)
[Attachment].NET Microservices - Architecture for Containerized .NET Applications.pdf
Getting started with Blazor and Electron.NET
What is Blazor? From the Blazor Github, Blazor is "an experimental .NET web framework using C#/Razor and HTML that runs in the browser via WebAssembly" What is Electron.NET? From the Electron.NET Github, "Electron.NET is a wrapper around a "normal" Electron application with an embedded ASP.NET Core application". Perquisites:
So that this article does not get dated with irreverent information quickly I will be using information from other resources. getting started for blazor node.js v8.6.0+ electron-packager --global Sample Project Github:
If you do not want to follow the steps below, or just want to check out the code I reproduced the following steps in a repo. Besure you all the required perquisites https://github.com/mandrepont/blazetron Setting up a simple project:
If you have not done so, check out the getting started for blazor to install perquisites for this tutorial Create a new Blazor (ASP.NET Core hosted) project Install ElectronNET.API PM> Install-Package ElectronNET.API
In %projectname%.Server/Program.cs change BuildWebHost to use Electron public static IWebHost BuildWebHost(string args) => WebHost.CreateDefaultBuilder(args) .UseElectron(args) .UseStartup<Startup>() .Build();
In %projectname%.Server/Startup.cs change Configure to open Electron app.UseBlazor<Client.Program>(); Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());
Add cli tooling to %projectname%.Server <ItemGroup> <DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.9" /> </ItemGroup>
Note at the time the current version is 0.0.9 dotnet restore Install electron packager sudo npm install electron-packager --global
Init and Run
dotnet electronize init
dotnet electronize start
I claim none of this work as my own and proudly support the work of both the aspnet team on Blazor and the team developing Electron.NET, this post is intended to raise awareness of some of the possibilities for a prototype. Most of the "Setting up a simple project" is directly from both Electron.NET's and Blazor's githubs.