{IL_0000: nop}
{IL_0001: ldarg.0}
{IL_0002: call System.String get_FirstName()}
{IL_0007: brfalse.s IL_0011}
{IL_0009: ldarg.0}
{IL_000a: call Boolean get_IsActive()}
{IL_000f: br.s IL_0012}
{IL_0011: ldc.i4.0}
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.Collections.Generic; | |
using System.Text; | |
using System.Threading.Tasks; | |
using LangExt; | |
namespace LangExt.Guard | |
{ | |
public static class Control | |
{ |
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
public static int[] QuickSort(int[] arr) | |
{ | |
if (!arr.Any()) return new int[] { }; | |
var p = arr.First(); | |
var xs = arr.Skip(1); | |
var lesser = xs.Where(x => x < p).ToArray(); | |
var greater = xs.Where(x => x >= p).ToArray(); | |
return (QuickSort(lesser).Concat(new[] { p }).Concat(QuickSort(greater))).ToArray(); |
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.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Diagnostics; | |
namespace Option2 | |
{ | |
public class Placeholder | |
{ |
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
Instruction ConditionalBranch(Instruction instruction, Func<Expression, BinaryExpression> condition) | |
{ | |
var val1 = stack.Pop(); | |
var test = condition(val1); | |
var left = (Instruction)instruction.Operand; | |
var right = instruction.Next; | |
Instruction common = GetJoinPoint(left, right); |
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
Expression.Lambda<Func<object>>(Expression.Convert(Expression.Default(t),typeof (object))).Compile()() == null |
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
-- disable referential integrity | |
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' | |
GO | |
EXEC sp_MSForEachTable 'TRUNCATE TABLE ?' | |
GO | |
-- enable referential integrity again | |
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL' | |
GO |
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
let rec move (x, y) r g n = | |
if x < 0 || y < 0 || x > g || y > g then n | |
elif (x,y) = (g, g) then n + 1 | |
else match List.tryFind ((=) (x, y)) r with | |
| Some _ -> n | |
| None -> | |
[(x + 1, y); (x, y + 1); (x - 1, y); (x, y - 1)] | |
|> List.map (fun xy -> move xy ((x, y)::r) g) | |
|> List.fold (|>) n | |
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
type LogicalCallContextEvent<'T>() = | |
let id = Guid.NewGuid() | |
member this.Publish = this :> IDelegateEvent<Handler<'T>> | |
member this.Trigger(arg:'T) = | |
if CallContext.LogicalGetData(id.ToString()) <> null then | |
(CallContext.LogicalGetData(id.ToString()) :?> Handler<'T>).Invoke(this, arg) | |
interface IDelegateEvent<Handler<'T>> with |
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
type ThreadLocalEvent<'T>() = | |
let handlers = new ThreadLocal<Handler<'T>>() | |
member this.Publish = this :> IDelegateEvent<Handler<'T>> | |
member this.Trigger(arg:'T) = | |
if handlers.Value <> null then | |
handlers.Value.Invoke(this, arg) | |
interface IDelegateEvent<Handler<'T>> with |
NewerOlder