Skip to content

Instantly share code, notes, and snippets.

View GraemeF's full-sized avatar

Graeme Foster GraemeF

View GitHub Profile
@GraemeF
GraemeF / gist:758979
Created December 29, 2010 19:51
Repro exception posting an object with an enum
using System.Net;
using EasyHttp.Http;
using Should.Fluent;
using Xunit;
namespace Tests
{
public class HttpClientTests
{
[Fact]
JsonFx.Serialization.SerializationException: JsonFx.Serialization.SerializationException : Object reference not set to an instance of an object.
---- System.NullReferenceException : Object reference not set to an instance of an object.
at JsonFx.Serialization.DataWriter`1.Write(Object data)
Codecs\DefaultCodec.cs(89,0): at EasyHttp.Codecs.DefaultCodec.Encode(Object data, String contentType)
Http\HttpRequest.cs(198,0): at EasyHttp.Http.HttpRequest.SetupBody()
Http\HttpRequest.cs(215,0): at EasyHttp.Http.HttpRequest.MakeRequest()
Http\HttpClient.cs(149,0): at EasyHttp.Http.HttpClient.ProcessRequest()
Http\HttpClient.cs(114,0): at EasyHttp.Http.HttpClient.Post(String uri, Object data, String contentType)
internal class MyModuleLocator : INancyModuleLocator
{
private readonly FooModule _fooModule;
public MyModuleLocator(IFoo foo)
{
_fooModule = new FooModule(foo);
}
public IEnumerable<NancyModule> GetModules()
@GraemeF
GraemeF / gist:743368
Created December 16, 2010 13:02
MefNancyModuleLocator
[Export(typeof (INancyModuleLocator))]
public class MefNancyModuleLocator : INancyModuleLocator
{
[ImportMany(typeof (NancyModule), AllowRecomposition = true)]
private IEnumerable<NancyModule> _modules;
public IEnumerable<NancyModule> GetModules()
{
return _modules;
}
PasteNodesCommand test = BuildDefaultTestSubject();
bool eventRaised = false;
test.CanExecuteChanged += (sender, args) => eventRaised = true;
ClipboardHasItemsChangesTo(true);
Assert.IsTrue(eventRaised);
@GraemeF
GraemeF / gist:500370
Created July 30, 2010 11:46
Behavior which allows the clipboard RoutedCommands to be mapped to other commands
public class ClipboardBehavior : Behavior<Control>
{
public static readonly DependencyProperty CopyCommandProperty =
DependencyProperty.Register("CopyCommand",
typeof (ICommand),
typeof (ClipboardBehavior),
new PropertyMetadata(default(ICommand)));
public static readonly DependencyProperty CutCommandProperty =
DependencyProperty.Register("CutCommand",
private TPart ComposePartWith<TPart, TImport>(TImport import)
{
var childContainer = new CompositionContainer(Container);
childContainer.ComposeExportedValue(import);
return childContainer.GetExportedValue<TPart>();
}