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 Autofac; | |
using Newtonsoft.Json.Serialization; | |
/// Allows constructor dependencies to be resolved when deserializing JSON.NET instances. | |
public class DependencyContractResolver : DefaultContractResolver | |
{ | |
/// But what if I wanted to extend CamelCasePropertyNamesContractResolver instead of | |
/// DefaultContractResolver in some cases? No way to switch it out without delegation. |
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
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions | |
Enable-RemoteDesktop | |
cinst fiddler4 | |
cinst git-credential-winstore | |
cinst console-devel | |
cinst sublimetext2 | |
cinst poshgit | |
cinst dotpeek |
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
[<RequireQualifiedAccess>] | |
type DBusType = | |
| Byte | |
| Boolean | |
| Int16 | |
| UInt16 | |
| Int32 | |
| UInt32 | |
| Int64 | |
| UInt64 |
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
open System | |
type Disposable() = | |
do printfn "Constrcuted!" | |
interface IDisposable with | |
member x.Dispose() = printfn "Disposed!" | |
let sequence = | |
seq { | |
use disposable = new Disposable() |
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
// State types | |
type Ping = Ping | |
type Pong = Pong | |
// Builder that requires every "ping" to be | |
// immediately answered by a "pong" | |
type PingBuilder() = | |
member __.Yield(()) = Pong | |
member __.Run(Pong) = () |
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 CalcBuilder() = | |
member __.Yield(()) = () | |
member __.Run((x, ())) = x | |
[<CustomOperation("push")>] | |
member __.Push(rest, x) = (x, rest) | |
[<CustomOperation("add")>] | |
member __.Add((y, (x, rest))) = (x + y, rest) |
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 annotateMember data (memb:'t :> #MemberInfo) = | |
match box memb with | |
| :? EventInfo as event -> | |
{ new EventInfoProxy(event) with | |
override __.GetCustomAttributesData() = data } :> 't | |
| :? MethodInfo as meth -> | |
{ new MethodInfoProxy(meth) with | |
override __.GetCustomAttributesData() = data } :> 't | |
| :? PropertyInfo as prop -> | |
{ new PropertyInfoProxy(prop) 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 JObject = JProperty list | |
and JProperty = string * JValue | |
and JValue = | |
| JString of string | |
| JInt of int | |
| JObject of JObject | |
| JArray of JValue list | |
let rec renderJson jObject = | |
let quote value = sprintf "\"%s\"" value |
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
// Functor instances. Define Functor as a single case discriminated union | |
// to help with overload resolution. | |
type Functor = Functor with | |
static member fmap(Functor, mapping, option) = Option.map mapping option | |
static member fmap(Functor, mapping, list) = List.map mapping list | |
// Helper function to resolve Functor overload. Needed because we can't specify a concrete type | |
// such as Functor in a statically-resolved type parameter constraint, so we instead pass in an | |
// instance of Functor to resolve the ^o parameter. Also notice we have ^c and ^d instead of | |
// ^f< ^a > and ^f < ^b > because F# doesn't allow this. |
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 class GuidLayout : RawPropertyLayout | |
{ | |
public override object Format(LoggingEvent loggingEvent) | |
{ | |
var baseFormat = base.Format(loggingEvent); | |
if (baseFormat is Guid) | |
return baseFormat; | |
var guidString = baseFormat as string; |
NewerOlder