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 MiniColour = { | |
| Id : string | |
| Name : string | |
| Hex : string | |
| } | |
| type MiniMyColoursDto = { Colours : MiniColour list } | |
| let toMiniColour (c : Colour) = { MiniColour.Id = c.Id; Name = c.Name; Hex = c.Hex } |
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 customJsonContentType mimeType data next (ctx : HttpContext) = | |
| sprintf "%s; charset=utf-8" mimeType |> ctx.SetContentType | |
| let serializer = ctx.GetJsonSerializer() | |
| serializer.SerializeToBytes data | |
| |> ctx.WriteBytesAsync | |
| type CustomNegotiationConfig (baseConfig : INegotiationConfig) = | |
| interface INegotiationConfig with | |
| member __.UnacceptableHandler = | |
| baseConfig.UnacceptableHandler |
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
| struct Colour: Decodable { | |
| var id: String | |
| var name: String | |
| var hex: String | |
| } | |
| var colours: [Colour] = [] | |
| private func loadColours() { | |
| let url = URL(string: "http://localhost:5000/my-colours") |
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 Colour = { | |
| Id : string | |
| Name : string | |
| Hex : string | |
| RGB : RGB | |
| HSL : HSL | |
| } | |
| and RGB = { Red : int; Green : int; Blue : int } | |
| and HSL = { Hue : int; Saturation : int; Lightness : int } |
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 ConfigurationProvider | |
| { | |
| public int TimeoutSeconds => | |
| Int32.Parse(Environment.GetEnvironmentVariable("TIMEOUT_SECONDS")); | |
| public Uri Endpoint => | |
| new Uri(Environment.GetEnvironmentVariable("ENDPOINT")); | |
| public int RetryCount => | |
| Int32.Parse(Environment.GetEnvironmentVariable("RETRY_COUNT")); | |
| } |
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 interface IConfigurationProvider | |
| { | |
| int TimeoutSeconds { get; } | |
| Uri Endpoint { get; } | |
| int RetryCount { get; } | |
| } |
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
| private static Thing MakeThing(string thingName, int thingVal, string thirdParam) | |
| { | |
| if (thingName == null) | |
| throw new ArgumentNullException(nameof(thingName)); | |
| if (thirdParam == null) | |
| throw new ArgumentNullException(nameof(thirdParam)); | |
| return new Thing(thingName, thingVal, thirdParam); | |
| } |
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
| //lurking within other code | |
| var thingFac = new ThingFactory(myThingName, myThingVal); | |
| var thing = thingFac.MakeThing(thirdParam); |
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 ThingFactory | |
| { | |
| public string ThingName { get; } | |
| public string ThingValue { get; } | |
| public ThingFactory(string thingName, int thingValue) | |
| { | |
| if (thingName == null) | |
| throw new ArgumentNullException(nameof(thingName)); | |
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 AsyncResult = | |
| let map f x = | |
| async { | |
| let! x' = x | |
| return x' |> Result.map f | |
| } | |
| let bind f x = | |
| async { |