Skip to content

Instantly share code, notes, and snippets.

View henkmollema's full-sized avatar

Henk Mollema henkmollema

View GitHub Profile
@henkmollema
henkmollema / RetryPolicyBehavior.cs
Last active August 7, 2023 19:04
Transient failure handling for MediatR using Polly
using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.Extensions.Logging;
using Polly;
namespace Foo.Bar
{
@henkmollema
henkmollema / Program.cs
Created December 27, 2018 11:05
MediatR generic dispatch
using System;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
namespace ConsoleApp3
{
public class Program
{
@henkmollema
henkmollema / Startup.cs
Created November 8, 2018 19:31
Consuming transient services from singletons
public class BarService
{
public DateTime Now { get; } = DateTime.UtcNow;
}
public class FooService
{
private readonly BarService _barService;
public FooService(BarService barService)
@henkmollema
henkmollema / DebuggableAssemblyExtensions.cs
Created November 3, 2016 16:13
DebuggableAssemblyExtensions
using System.Diagnostics;
using System.Reflection;
namespace Novusoft.Fms.Templates
{
public static class DebuggableAssemblyExtensions
{
private static readonly FieldInfo _debuggingModeField = typeof(DebuggableAttribute).GetField("m_debuggingModes", BindingFlags.NonPublic | BindingFlags.Instance);
/// <summary>
public class ClassA
{
public Task TheTask;
public string Result;
public ClassA()
{
TheTask = SomeLongMethod();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.Framework.Runtime;
namespace SomeApp
{
public class TypeFinder
{