This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* somewhere in your Core.CQRS */ | |
// Base class for all ES-based aggregate command handling components; | |
// | |
// NOTE: "Component" is a logical grouping of message handlers by function | |
// They provide good place to encapsulate chaining of cross-cutting concerns | |
// into a pipeline, providing simplified helper methods for registration of message handlers | |
// | |
// Components are similar to Services, thus they only contain handlers of single type (ie Command Handlers only) | |
// Components operate on envelope (infrastructure) level |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if DEBUG | |
public static XYZ Normalize(this XYZ c, [CallerMemberName] string caller = "") | |
#else | |
public static XYZ Normalize(this XYZ c) | |
#endif | |
{ | |
#if DEBUG // completely needless | |
Debug.Print("normalizing: {0} called from: {1}", c, caller); | |
#endif | |
return new XYZ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
static class LiftingClosureToDelegateTarget { | |
static void Main() { | |
// normal lambda | |
{ | |
var str = GetString(); | |
Func<string> f = () => str; | |
Console.WriteLine(f()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class BooleanSolver { | |
class T { | |
public static T operator |(T x, T y) => null; | |
public static T operator |(T x, F y) => null; | |
public static T operator &(T x, T y) => null; | |
public static F operator &(T x, F y) => null; | |
public static F operator !(T x) => null; | |
} | |
class F { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
// What argument do you need to provide to this method so that it returns true? | |
public static bool AreYouNuts<T>(T[] array) | |
{ | |
if (array == null || array.Length == 0) | |
return false; | |
var local = (T[]) array.Clone(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using N; // This using directive is unused, but cannot be simply removed | |
static class C | |
{ | |
static void Ex(this string x) { } | |
static void Foo(Action<string> x, int y) { } | |
static void Foo(Action<string> x, string y) { } | |
static void Foo(Action<string> x, object y) { } | |
static void Foo(Action<int> x, int y) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
unsafe struct S | |
{ | |
public void* ptr; | |
public object obj; | |
static void Main() | |
{ | |
S s = default(S); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Base | |
{ | |
private string x = "x".Print(); | |
} | |
class Derived : Base | |
{ | |
private string y = "y".Print(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
class Program | |
{ | |
static void Main() | |
{ | |
dynamic calc = Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid(148736, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70))); | |
Console.WriteLine(calc.Evaluate("2+3*5")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel; | |
using System.Linq; | |
class Program { | |
static void Main(string[] args) { | |
Console.WriteLine("Attributes: " + typeof(Program) | |
.GetMembers() | |
.SelectMany(m => m.GetCustomAttributes(true)) | |
.Count() |
OlderNewer