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 Person | |
{ | |
private readonly PersonState _state; | |
public Person(string name) | |
{ | |
_state = new PersonState(name); | |
} | |
public string GetName() |
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
namespace Money | |
{ | |
public class Money<TCurrency> where TCurrency : ICurrency | |
{ | |
private readonly decimal _value; | |
public Money(decimal value) | |
{ | |
_value = 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
@echo off | |
cls | |
"NuGet.exe" "Install" "FAKE" "-OutputDirectory" "packages" "-ExcludeVersion" | |
"packages\FAKE\tools\Fake.exe" build.fsx %* | |
pause |
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 | |
[<AutoOpen>] | |
module FileHelper = | |
type FileCheck = | |
{ | |
FileName: string | |
Size: int64 | |
} |
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 | |
let digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";; | |
let ex = "101010101011101010101011101010101011101010101011";; | |
let convert (chars:string) (ul) = | |
let baseLength = (int64 (chars.Length)) | |
let rec convert' (acc,rest) = | |
if rest = 0L then acc |> List.rev | |
else convert' (chars.[int (rest % baseLength)]::acc,(rest/baseLength)) | |
convert' ([],ul) |
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
module Car | |
type Make = Make of string | |
type Color = Color of string | |
type Year = Year of int | |
type Car = private {Make: Make; Year: Year; Color: Color} | |
with | |
member a.PrintYear() = printfn "%A" a.Year | |
let print (a:Car) = printfn "%A" a // Car+Car |
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 SokEnhet : ISokEnhet<ElasticSearchKonsesjon> | |
{ | |
public Guid Id { get; set; } | |
public EnhetNummer Enhetsnummer { get; set; } | |
[JsonProperty(TypeNameHandling = TypeNameHandling.Objects)] | |
public IEnhetNavn Navn { get; set; } | |
public string IndeksertNavn => Navn != null ? Navn.LagKortversjon() : ""; | |
public EnhetType Enhetstype { get; set; } | |
public string KortAdresse { get; set; } | |
public List<ElasticSearchKonsesjon> Konsesjoner { get; set; } = new List<ElasticSearchKonsesjon>(); |
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 | |
open System.Drawing | |
open System.Windows.Forms | |
// Create a form to display the graphics | |
let width, height = 1000, 1000 | |
let form = new Form(Width = width, Height = height) | |
let box = new PictureBox(BackColor = Color.White, Dock = DockStyle.Fill) | |
let image = new Bitmap(width, height) |
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
Stacktrace: | |
at <unknown> <0xffffffff> | |
at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0xffffffff> | |
at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x00053> | |
at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x0005f> | |
at System.MonoCustomAttrs.RetrieveAttributeUsageNoCache (System.Type) <0x00063> | |
at System.MonoCustomAttrs.RetrieveAttributeUsage (System.Type) <0x000ab> | |
at System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x000ff> | |
at System.MonoType.IsDefined (System.Type,bool) <0x0001f> |
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
module CachingAgent | |
open System | |
type AgentCacheMessage<'T> = AsyncReplyChannel<'T> | |
type Agent<'T> = MailboxProcessor<'T> | |
let CreateCache<'T> timespan (funcGen:Func<'T>) = Agent.Start(fun inbox -> | |
let rec loop expire (cached:Lazy<'T>) = async { | |
let! (message:AgentCacheMessage<'T>) = inbox.Receive() | |
let renew = expire <= DateTime.Now | |
let cached' = if renew then lazy (funcGen.Invoke()) else cached |