Skip to content

Instantly share code, notes, and snippets.

void DoSomethingToNode(BindingNode node)
{
switch (node)
{
case<BindingLiteral> foo:
foo.LiteralText += "blah";
break;
case<BindingNameReference> bar:
break;
<!-- bindings.xml -->
<bind element="display">Html.DisplayFor(m=>@for, "@template")</bind>
<bind element="display">Html.DisplayFor(m=>@for)</bind>
<bind element="a">Html.ActionLink("child()", "@action", "@controller", new{"@route.*"}, new{"@*"})</bind>
<bind element="a">Html.ActionLink("child()", "@action", new{"@route.*"}, new{"@*"})</bind>
<!-- sample.spark -->
<display for="m.ShipTo"/>
<display for="m.ShipTo" template="smalladdr"/>
<display for="m.ShipTo" template="${bar}"/>
public Result App1(IDictionary<string, object> env) {
var request = new Request(env);
request.Logger.Info("Calling " + request.ScriptName);
return new Result(
200,
new Dictionary<string, object>{{"Content-Type","text/plain"}},
new[]{"<p>You are looking at", request.ScriptName, "</p>"});
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
namespace FuncGist {
// signature exposed by middleware and app
@loudej
loudej / ObservableExtensions.cs
Created December 28, 2010 07:59
observable + task
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
namespace FuncGist {
public static class ObservableExtensions {
public static Task Subscribe<T>(this IObservable<T> observable, Action<T> next) {
@loudej
loudej / gist:771534
Created January 9, 2011 08:31
Making obs from stuff
public class Examples {
public void Foo() {
// these vars are all IObservable<string>
var src1 = Obs.Unit("one");
var src2 = Obs.Create(
new[] { "one", "two", "three" });
var src3 = Obs.Create<string>(write => {
write("one");
@loudej
loudej / body.cs
Created May 13, 2011 18:08
IObservable body
using IBodyObservable = IObservable<Tuple< // body
ArraySegment<byte>, // data
Action, // delay
Action>>; //continuation
using BodyDelegate = Func< // body
Action< // next
ArraySegment<byte>, //data
Action, // continuation
bool>, // delayed
@loudej
loudej / Program.cs
Created May 13, 2011 21:58
Larger example
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ObsBody
{
internal class Program
@loudej
loudej / HomeController.cs
Created November 14, 2011 18:37
asp.net does not actually support multiple same-named incoming headers
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Web.Mvc;
namespace HeaderChecking.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
@loudej
loudej / gist:1684468
Created January 26, 2012 19:15
BodyDelegate
// current delegate
Action /*cancel*/ BodyDelegate(
Action<ArraySegment<byte>, Action, bool> next,
Action<Exception> error,
Action complete);
// node-like delegate
void BodyDelegate(
Action<ArraySegment<byte>, bool> write,
Action<Action, bool> flush,