- Install Chocolatey
- Reopen console application (for example
cmd.exe
) to update%PATH%
and other environment variables - Install ScriptCs using chocolatey
- Save both
Roslyn-EvalSample.csx
andpackages.config
- Install dependencies using
scriptcs -install
- Run
scriptcs .\Roslyn-EvalSample.csx
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
void Main() | |
{ | |
// create kernel with conventions | |
using(var kernel = InitializeKernel()) | |
{ | |
var backend = kernel.Get<IBackend>(); | |
Assert.That(backend, Is.Not.InstanceOfType(typeof(ProdBackend)) | |
.And.InstanceOfType(typeof(TestBackend))); | |
} |
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
Write-Host 'throw' | |
try | |
{ | |
try | |
{ | |
throw "exception" | |
} | |
catch | |
{ |
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
#time "on" | |
#load "Bootstrap.fsx" | |
open System | |
open Akka.Actor | |
open Akka.Configuration | |
open Akka.FSharp | |
open Akka.TestKit | |
// #Using Actor |
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
void Main() | |
{ | |
using(var kernel = new StandardKernel(new Module())) | |
{ | |
kernel.Load<FuncModule>(); // for sake of LinqPAD | |
var instance1 = kernel.Get<MyClass>(new ConstructorArgument("myArg", "test")); | |
var instance2 = kernel.Get<MyClass>(new ConstructorArgument("myArg", "test")); | |
Assert.That(instance1, Is.Not.Null.And.SameAs(instance2)); |
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
import socket | |
import sys | |
from contextlib import contextmanager | |
import click | |
so_reuseport = socket.SO_REUSEPORT | |
@contextmanager |
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
#I @".\packages\FsCheck.0.9.2.0\lib\net40-Client\" | |
#r @"FsCheck.dll" | |
// #time "on" | |
open FsCheck | |
// simple example | |
let revRevIsOrig (xs:list<int>) = List.rev(List.rev xs) = xs | |
Check.Quick revRevIsOrig;; |
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
void Main() | |
{ | |
TraceDecorator.Aspect(() => StaticLogic.SuccessfulCall()); | |
TraceDecorator.Aspect(() => StaticLogic.ExceptionCall()); | |
TraceDecorator.Aspect(() => StaticLogic.SuccessfulCallWithReturn(42)).Dump(); | |
TraceDecorator.Aspect(() => StaticLogic.ExceptionCallWithReturn(42)).Dump(); | |
} | |
public static class TraceDecorator | |
{ |
This gist contains:
- ExecuteScriptCs.cs — class that are able to execute ScriptCs from another .Net application
- ScriptModule.cs — AutoFac configuration for ScriptCs/NuGet dependencies
- Program.cs — command-line example
- Sample.csx — sample ScriptCs script
- packages.config — NuGet packages configuration
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
void Main() | |
{ | |
ProxyGenerator proxyGenerator = CreateProxyGenerator(); | |
IService proxy = | |
proxyGenerator | |
.CreateInterfaceProxyWithTargetInterface(new Service() as IService, new TracingInterceptorAspect()); | |
proxy.ProcessRequest(); | |
NewerOlder