Skip to content

Instantly share code, notes, and snippets.

using System;
namespace WizardsAndWarriors
{
public class Program
{
public static void Main(string[] args)
{
IPlayer player = new Wizard();
Console.WriteLine(player.Weapon.Damage);
@markrendle
markrendle / output.txt
Created May 28, 2015 14:53
Output from trying to build Microsoft.WindowsAzure.Storage with primary sources against DnxCore50
/home/mark/cloudlens/azure-storage-net/Lib/Common/RequestEventArgs.cs(59,16): error CS0246: The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/RequestEventArgs.cs(65,16): error CS0246: The type or namespace name 'HttpWebResponse' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/RequestResult.cs(34,6): error CS0246: The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/StorageException.cs(44,6): error CS0246: The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)
/home/mark/cloudlens/azure-storage-net/Lib/Common/StorageException.cs(109,44): error CS0246: The type or namespace name 'SerializationInfo' could not be found (are
@markrendle
markrendle / Person.cs
Created June 3, 2015 20:22
Backwards compatibility is hard
namespace PersonApp
{
public class Person
{
public Person()
{
}
private Person(string firstName, string lastName)
@markrendle
markrendle / ClaimsMiddleware.cs
Last active August 29, 2015 14:23
Middleware example
using System.Linq;
using Microsoft.AspNet.Builder;
namespace StealthProject.Mvc
{
public static class AuthenticationMiddleware
{
private static readonly char[] Eq = { '=' };
public static IApplicationBuilder UseHeaderClaims(this IApplicationBuilder app)
obj
bin
deploy
*.csproj.user
*.suo
*.cache
~$*
(define contains
(lambda (list item)
(and (not (null? list))
(or (= item (car list))
(contains (cdr list) item)))))
(define hasdup
(lambda (list)
(and (not (null? list))
(or (contains (cdr list) (car list))
@markrendle
markrendle / teaser.cs
Created June 4, 2014 14:21
Simple.Data v2 teaser
class Tease
{
private readonly dynamic _db = Database.Open();
public async void DoSomeStuff()
{
// Async by default
Customer customer = await _db.Customers.Get(42).WithOrders();
// Batch operations
public class ClaimsPrincipalBuilder
{
public static ClaimsPrincipal FromDictionary(IDictionary<string, string> source)
{
var claims = source.Select(pair => new Claim(pair.Key, pair.Value));
var identity = new ClaimsIdentity(claims);
return new ClaimsPrincipal(identity);
}
}
using System;
namespace OverloadResolutionChallenge
{
class Program : One
{
static void Foo<T>(T? t = default(T?)) where T : struct
{
Console.WriteLine("struct");
}
@markrendle
markrendle / TaskEx.cs
Created June 14, 2011 13:09
DelayedStart extension for System.Threading.Tasks.Task
public static class TaskEx
{
private static readonly ConcurrentDictionary<Task, Timer> Timers = new ConcurrentDictionary<Task, Timer>();
public static Task DelayedStart(this Task task, TimeSpan delay)
{
var timer = new Timer(_ => Start(task), null, (long)delay.TotalMilliseconds, -1L);
Timers.AddOrUpdate(task, timer, (k, t) => t);
return task;
}