What does Dependency Injection mean by saying it can inject at runtime?

The service type is defined at compile time. This is normally in the form of an interface or a (sometimes abstract) base class. The key point here is Liskovs substitution principle It states that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects… Read more →

Enumerable Debugger

using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Bw.Sipp { public static class EnumerableDebugger { public static IEnumerable<T> Dump<T>(this IEnumerable<T> input) { return Dump( input, item => item != null ? Newtonsoft.Json.JsonConvert.SerializeObject(item) : “(null)”); } public static IEnumerable<T> Dump<T>( this IEnumerable<T> input, Func<T, string> toString) { foreach (var item in input) { Debug.WriteLine(toString(item)); yield return… Read more →

PresentationFeb2021

I saw a request a while ago asking for advice on some kind diagnostic logging (I can’t recall the details other than the person who asked). Worded another way the question is: how do apply a cross-cutting concern? When we: design our solutions around the ideas of queues, messages, events and streams & services (aka queries & commands) write code… Read more →

Exception capture in .NET Core

app.UseExceptionHandler(options => { options.Run( async context => { var error = context.Features.Get<IExceptionHandlerFeature>(); if (error is object) { Log.Error( “EXCEPTION {method} {url} {query} => {exception}”, context.Request.Method, context.Request.Path.Value, context.Request.QueryString.Value, error.Error); } }); }); Read more →

Debug XmlSerializer

var serializer = new XmlSerializer(typeof(<x>)); serializer.UnknownAttribute += (sender, args) => System.Diagnostics.Debug.Fail($”Unknown attribute { args.Attr.Name }=\'{ args.Attr.Value }\'”); serializer.UnknownNode += (sender, args) => System.Diagnostics.Debug.Fail($”Unknown Node: {args.Name}\t{args.Text}”); serializer.UnknownElement += (sender, args) => System.Diagnostics.Debug.Fail($”Unknown Element: { args.Element.Name }\t{ args.Element.InnerXml}”); serializer.UnreferencedObject += (sender, args) => System.Diagnostics.Debug.Fail($”Unreferenced Object: { args.UnreferencedId }\t{ args.UnreferencedObject.ToString() }”); Read more →