This file contains 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
static void Main() | |
{ | |
IObservable<int> observable = Enumerable.Range(0, 10).ToObservable(); | |
// Long version | |
observable.Subscribe(new IntObserver()); | |
// Short version (lambda) | |
observable.Subscribe(Console.WriteLine) | |
This file contains 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 static class RxExamples | |
{ | |
// Equal to Observable.Empty<T>() | |
public static IObservable<T> Empty<T>() | |
{ | |
return Observable.Create<T>(observer => | |
{ | |
observer.OnCompleted(); | |
return Disposable.Empty; | |
}); |
This file contains 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
[System.Runtime.InteropServices.DllImport("KERNEL32.DLL")] | |
private static extern int GetSystemDefaultLCID(); | |
private RegionInfo CurrentRegionInfo() | |
{ | |
var cultureInfo = new CultureInfo(GetSystemDefaultLCID()); | |
return new RegionInfo(cultureInfo); | |
} | |
// OR (it's preferable if Vista or higher) |
This file contains 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 FSharp.Data | |
open FSharp.Data.JsonExtensions | |
open System.IO | |
open System | |
module City = | |
type T = City of string | |
let Kyiv = City "Киев" | |
let Kharkiv = City "Харьков" |
This file contains 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 FinanceRevised.Core | |
open FinanceRevised.Types | |
open MaybeBuilder | |
open System | |
open System.IO | |
open FSharp.Data | |
open FSharp.Data.JsonExtensions |
This file contains 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 AsyncTimer(duration) = | |
let tickEvent = new Event<_>() | |
let endEvent = new Event<_>() | |
[<CLIEvent>] | |
member this.Tick = tickEvent.Publish | |
[<CLIEvent>] | |
member this.End = endEvent.Publish |
This file contains 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.Linq; | |
using System.Text; | |
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp; | |
using Microsoft.CodeAnalysis.CSharp.Syntax; | |
namespace ConsoleRoslyn_1 | |
{ | |
class MyTokenWalker : CSharpSyntaxWalker |
This file contains 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
// Remove all nuget packages from project | |
$packages = Get-Package -ProjectName MyProjectName; | |
foreach($package in $packages) { | |
Uninstall-Package -ProjectName MyProjectName -Id $package.Id -Force | |
} | |
// Remove all nuget packages from all projects from solution | |
foreach($project in $projects) { |
This file contains 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 apply optionF optionStr = | |
match optionF,optionStr with | |
| Some f, Some str -> Some (f str) | |
| _ -> None | |
let repeat count (str:string) = String.replicate count str | |
let mul x y = x * y | |
let optionMul = Option.map mul | |
let retn x = Some x // official naming for upgrading a value |
This file contains 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
interface Person { | |
age: number, | |
name: string, | |
say(): string | |
} | |
let mike = { | |
age: 25, | |
name:"Mike", | |
say: function() { |
OlderNewer