Skip to content

Instantly share code, notes, and snippets.

View GraemeF's full-sized avatar

Graeme Foster GraemeF

View GitHub Profile
private TPart ComposePartWith<TPart, TImport>(TImport import)
{
var childContainer = new CompositionContainer(Container);
childContainer.ComposeExportedValue(import);
return childContainer.GetExportedValue<TPart>();
}
@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",
PasteNodesCommand test = BuildDefaultTestSubject();
bool eventRaised = false;
test.CanExecuteChanged += (sender, args) => eventRaised = true;
ClipboardHasItemsChangesTo(true);
Assert.IsTrue(eventRaised);
@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;
}
internal class MyModuleLocator : INancyModuleLocator
{
private readonly FooModule _fooModule;
public MyModuleLocator(IFoo foo)
{
_fooModule = new FooModule(foo);
}
public IEnumerable<NancyModule> GetModules()
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)
@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]
@GraemeF
GraemeF / gist:761145
Created December 31, 2010 16:51
NuGet error
---------------------------
Microsoft Visual Studio
---------------------------
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd' has invalid child element 'created' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'. List of possible elements expected: 'iconUrl, dependencies, licenseUrl, projectUrl, title, tags, summary, owners' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'.
@GraemeF
GraemeF / gist:762627
Created January 2, 2011 16:28
SimpleValue
public abstract class SimpleValue<TValue>
{
private TValue _value;
protected SimpleValue(TValue value)
{
Value = value;
}
private TValue Value
System.ArgumentException: System.ArgumentException : You must declare a backing field for this property named: _MyProperty
at ReactiveXaml.RxApp.getFieldInfoForProperty[TObj](String prop_name)
at ReactiveXaml.ReactiveNotifyPropertyChangedMixin.ObservableForProperty[TSender,TValue](TSender This, Expression`1 Property, Boolean BeforeChange)