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; | |
| public interface Maybe<T> { } | |
| public class Nothing<T> : Maybe<T> { } | |
| public class Just<T> : Maybe<T> { | |
| public T Value { get; private set; } |
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
| return TryGetCachedData(message, metadata, request).Match( | |
| some: data => CachedResult(message.RequestId, data, stats), | |
| none: () => Result(message, context, metadata, request, stats)); |
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
| void Foo(string bar) { | |
| bar = bar.Trim(); | |
| } |
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 _rnd = System.Random() | |
| let rand min max = _rnd.Next(min, max) | |
| type Choice = | Yes | No | |
| let addDoors = function | |
| | (1, _) -> [| "dragon"; "goat"; "goat" |] | |
| | (0, 1) -> [| "goat"; "dragon"; "goat" |] | |
| | (0, 0) -> [| "goat"; "goat"; "dragon" |] | |
| | (_, _) -> failwith "Option is out of range" |
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
| // helpers | |
| let inc x = x + 1 | |
| let dec x = x - 1 | |
| let even x = x % 2 = 0 | |
| // adding and subtracting one | |
| let rec add1 lst = | |
| if List.isEmpty lst then [] | |
| else (List.head lst) + 1 :: add1 (List.tail lst) |
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 void Consume(ConnectorRequest message) | |
| { | |
| var context = ProcessMessageContext.Create(); | |
| var request = ProcessRequest(message, context); | |
| var timeout = BusinessTimeout(message.Timeout, context); | |
| Observable.Amb(request, timeout).Subscribe(SendResponse(message)); | |
| } |
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
| <connector id="xxx" useCache="true" maxAge="36000"> | |
| <data priority="2"> |
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
| container.Register( | |
| WcfClient.ForChannels(DefaultClientModel.On(WcfEndpoint. | |
| ForContract<IMultiConnectorService>(). | |
| FromConfiguration("HostedConnector")))); |
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
| var matchingPairs = from item in groups. | |
| Zip(groupNames, (group, name) => new { | |
| Pair = CreatePair(name, group.Value), | |
| IsMatch = group.Success, | |
| }) | |
| where item.IsMatch && IsValidKeyAndValue(item.Pair) | |
| select item.Pair; |
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
| bool success = false; | |
| try | |
| { | |
| // do something | |
| success = true; | |
| } | |
| catch { } | |
| Assert.True(success); |