Skip to content

Instantly share code, notes, and snippets.

View Calabonga's full-sized avatar
💭
Пишите правильный код

Calabonga Calabonga

💭
Пишите правильный код
View GitHub Profile
@Calabonga
Calabonga / ConfigureServicesMassTransit
Last active September 1, 2022 07:20
MassTransit (RabbitMQ) connection configuration for ASP.NET Core
/// <summary>
/// MassTransit configurations for ASP.NET Core
/// </summary>
public class ConfigureServicesMassTransit
{
/// <summary>
/// ConfigureServices
/// </summary>
/// <param name="services"></param>
/// <param name="configuration"></param>
@Calabonga
Calabonga / .filenesting.json
Last active January 10, 2021 12:19
Visual Studio file nesting
{
"help": "https://go.microsoft.com/fwlink/?linkid=866610",
"root": true,
"dependentFileProviders": {
"add": {
"extensionToExtension": {
"add": {
".razor.css": [
".razor"
],
@Calabonga
Calabonga / ILocalStorageService.cs
Created December 1, 2020 05:19
Blazor LocalStorageService
public interface ILocalStorageService
{
Task SetAsync<T>(string key, T item) where T: class;
Task SetStringAsync(string key, string value);
Task<T> GetAsync<T>(string key) where T: class;
Task<string> GetStringAsync(string key);
@Calabonga
Calabonga / docker-compose.yaml
Created February 3, 2021 02:07
docker-compose ElasticeSearch and Kibana
version: '3.1'
services:
elasticsearch:
container_name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
ports:
- 9200:9200
volumes:
root = true
# Remove the line below if you want to inherit .editorconfig settings from higher directories
[*.json]
indent_size = 4
indent_style = space
tab_width = 4
# C# files
[*.cs]
@Calabonga
Calabonga / TaskExtended.cs
Created June 22, 2021 03:08
Task extended version for catching all exceptions when all starts
public class TaskExtended
{
public static async Task<IEnumerable<T>> WhenAll<T>(params Task<T>[] tasks)
{
var allTasks = Task.WhenAll(tasks);
try
{
return await allTasks;
}

Layered Architecture

flowchart TD
    subgraph FEATURES
        Presentation --> Application
        Application --> Domain
        Domain --> Infrastructure
        Infrastructure --> Database
 end
@Calabonga
Calabonga / AsyncHelper.cs
Last active April 20, 2022 04:17
AsyncHelper helps to start asynchronous method as synchronously
public static class AsyncHelpers
{
/// <summary>
/// Executes an async Task<T> method which has a void return value synchronously
/// </summary>
/// <param name="task">Task<T> method to execute</param>
public static void RunSync(Func<Task> task)
{
var oldContext = SynchronizationContext.Current;
var synch = new ExclusiveSynchronizationContext();
@Calabonga
Calabonga / TaskHelper.cs
Created April 20, 2022 08:24
Run and forget task C#
public static class TaskHelper
{
/// <summary>
/// Runs a TPL Task fire-and-forget style, the right way - in the
/// background, separate from the current thread, with no risk
/// of it trying to rejoin the current thread.
/// </summary>
public static void RunBg(Func<Task> fn) => Task.Run(fn).ConfigureAwait(false);
/// <summary>
@Calabonga
Calabonga / xunit.runner.json
Last active April 29, 2022 03:21
xunit.runner.json
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"methodDisplay": "method",
"methodDisplayOptions": "all"
}