Note: for an detailed introduction see Step-by-step installation instructions for getting DNX on your Windows machine
1 Install the .NET Version Manager (dnvm
)
1a when already installed:
dnvm update-self
dnvm upgrade
/// <summary>Takes a list of values and scales the values, so that the sum of the result is always 1 (100%).</summary> | |
/// <param name="values">A list of values that need to be scaled.</param> | |
/// <returns>Scaled values, from which the sum is 1.</returns> | |
let scaleSoThatSumIsOne (values:seq<decimal>) = | |
let Σ = Seq.sum values | |
match Σ with | |
| 0.0m -> | |
let n = decimal (Seq.length values) | |
seq { | |
for p in values do |
// Used to exchange symmetric keys | |
private static int RsaKeySize = 2048; | |
private void CreateKeys() | |
{ | |
using(var provider = new RSACryptoServiceProvider(RsaKeySize)) | |
{ | |
provider.PersistKeyInCsp = false; | |
sing System; | |
using System.Reactive.Concurrency; | |
namespace ReactiveUI | |
{ | |
/// <summary> | |
/// IMessageBus represents an object that can act as a "Message Bus", a | |
/// simple way for ViewModels and other objects to communicate with each | |
/// other in a loosely coupled way. | |
/// |
using System; | |
using System.Runtime.Serialization; | |
using System.Xml.Serialization; | |
namespace CN.Lib.Types | |
{ | |
[Serializable] | |
[DataContract] | |
public struct Money : IEquatable<Money>, IComparable<Money>, IFormattable, ISerializable, IConvertible | |
{ |
using System; | |
using System.Linq; | |
using static System.Math; | |
namespace NominalSize | |
{ | |
public sealed class Size | |
{ | |
public Size(decimal basicValue, decimal upperTolerance, decimal lowerTolerance) | |
{ |
Note: for an detailed introduction see Step-by-step installation instructions for getting DNX on your Windows machine
1 Install the .NET Version Manager (dnvm
)
1a when already installed:
dnvm update-self
dnvm upgrade
public static class IntegerExtensions | |
{ | |
///<summary>Returns an enumerable range of integers</summary> | |
///<example><c>5.To(9)</c></example> | |
///<example><c>5.To(-3)</c></example> | |
public static IEnumerable<int> To(this int start,int end) | |
{ | |
var sign = Math.Sign(end - start); | |
while(start != end) | |
{ |
// inspired by FizzBuzz in Haskell by Embedding a Domain-Specific Language | |
// https://themonadreader.files.wordpress.com/2014/04/fizzbuzz.pdf | |
let fizzbuzz (number:int):string = | |
let test (d:int) (s:string) (x:string->string) = if number % d = 0 then (fun _ -> s + x("")) else x | |
let fizz = (fun (x:string->string) -> test 3 "Fizz" x) | |
let buzz = (fun (x:string->string) -> test 5 "Buzz" x) | |
((fun z -> z) |> buzz |> fizz) (number.ToString()); |
public static class LoggerExtensions | |
{ | |
public static ILogger Here(this ILogger logger, | |
[CallerMemberName] string memberName = "", | |
[CallerFilePath] string sourceFilePath = "", | |
[CallerLineNumber] int sourceLineNumber = 0) { | |
return logger | |
.ForContext("MemberName", memberName) | |
.ForContext("FilePath", sourceFilePath) | |
.ForContext("LineNumber", sourceLineNumber); |