Skip to content

Instantly share code, notes, and snippets.

View glikoz's full-sized avatar

Oguz Karadenizli glikoz

View GitHub Profile
@thiagomajesk
thiagomajesk / AutoFacModule.cs
Last active August 30, 2023 16:47
Generic Handlers & Commands for MediatR (+ AutoFac config)
public class GenericHandlersModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<CreateCommandHandler<Foo, CreateFooCommand>>().As<IRequestHandler<CreateFooCommand, bool>>();
builder.RegisterType<DeleteCommandHandler<Foo, DeleteFooCommand>>().As<IRequestHandler<DeleteFooCommand, bool>>();
builder.RegisterType<ListQueryHandler<Foo, ListFooQuery>>().As<IRequestHandler<ListFooQuery, IEnumerable<Foo>>>();
builder.RegisterType<UpdateCommandHandler<Foo, UpdateFooCommand>>().As<IRequestHandler<UpdateFooCommand, bool>>();
}
}
@ygrenier
ygrenier / ControllerExtensions.cs
Last active October 25, 2019 20:32
ASP.NET Core - Controller extension to test if a view exists
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Controller extensions
/// </summary>
public static class ControllerExtensions
{
@yallie
yallie / ipctest.cs
Created February 24, 2016 12:28
Sample IPC server for wrapping around the static class
// Compile this code using: csc ipctest.cs /r:Zyan.Communication.dll
// First run — starts server.
// Second run — starts client.
using System;
using System.Linq;
using System.Text;
using Zyan.Communication;
using Zyan.Communication.Protocols.Ipc;