Skip to content

Instantly share code, notes, and snippets.

View controlflow's full-sized avatar

Alexander Shvedov controlflow

View GitHub Profile
using System;
unsafe struct S
{
public void* ptr;
public object obj;
static void Main()
{
S s = default(S);
using System;
class Base
{
private string x = "x".Print();
}
class Derived : Base
{
private string y = "y".Print();
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"));
}
@yevhen
yevhen / gist:5199613
Created March 19, 2013 20:07
The concept of message handling Component and the example of message handler chaining via functional composition
/* 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
@controlflow
controlflow / gist:9996185
Last active January 10, 2018 08:17
C# 6.0 null-safe member access/method/indexer call use cases
nullness inspection
{
a?.M();
a.F(); // <= possible NRE
a?.M(a != null); // <= expression always true
}
inspection "Redundant null-propagation"
{
var a = new A();