Skip to content

Instantly share code, notes, and snippets.

View SimonCropp's full-sized avatar

Simon Cropp SimonCropp

View GitHub Profile
Exception Info: Stream was not readable.
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
at System.IO.StreamReader..ctor(Stream stream, Boolean detectEncodingFromByteOrderMarks)
at MetroTwit.Extensions.CommonCommands.<>c__DisplayClass85.<>c__DisplayClass8a.<CheckBoon>b__7c()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
public class Person : MyBaseClass
{
public string Name { get; set; }
}
public class MyBaseClass : GalaSoft.MvvmLight.ViewModelBase
{
protected virtual void Broadcast(object oldValue, object newValue, string propertyName)
{
var message = new PropertyChangedMessage(this, this, oldValue, newValue, propertyName);
@SimonCropp
SimonCropp / after
Created May 20, 2012 01:33
ILWeaving and ReactiveUI
public class Person : ReactiveObject
{
public string FamilyName
{
get { return this.<FamilyName>k__BackingField; }
set
{
if (!string.Equals(this.<FamilyName>k__BackingField, value))
{
base.raisePropertyChanging("FamilyName");
//the first context will be skipped in the foreach because the enumeration will be moved forward 1 by the allContexts.First(). Is this intentional
private string GetDestPath(ResolutionContext context)
{
var allContexts = GetContexts(context).Reverse();
var builder = new StringBuilder(allContexts.First().DestinationType.Name);
foreach (var ctxt in allContexts)
@SimonCropp
SimonCropp / creole-jambalaya.markdown
Created April 21, 2012 03:35 — forked from half-ogre/creole-jambalaya.markdown
How Drew makes jambalaya

Creole Jambalaya

This is how Drew makes jambalaya.

Ingredients

  • 2 tbsp. olive oil
  • 3 lbs. (~1.5kg) chicken pieces (I use bone-in thighs)
  • 1 cup all-purpose flour
  • 1 lb.(~500g) andouille sausage, sliced
@SimonCropp
SimonCropp / gist:2419965
Created April 19, 2012 09:36
Bypass Protected Constructor 2
public class BaseClass
{
protected BaseClass()
{
}
}
[TestFixture]
public class Foo2
@SimonCropp
SimonCropp / gist:2419932
Created April 19, 2012 09:25
Bypass Protected Constructor
public class BaseClass
{
protected BaseClass()
{
}
}
public class BypassClass : BaseClass
{
var path = @"F:\Code\CecilTest\TargetLibrary\bin\Debug\TargetLibrary.dll";
var moduleDefinition = ModuleDefinition.ReadModule(path);
var typeDefinition = moduleDefinition.Types.First(x => x.Name.EndsWith("Class1"));
var voidType = Type.GetType("System.Void");
var voidTypeReference = moduleDefinition.Import(voidType);
var methodDefinition = new MethodDefinition(".ctor", MethodAttributes.Public, voidTypeReference);
typeDefinition.Methods.Add(methodDefinition);
moduleDefinition.Write(path);
<UsingTask TaskName="NotifyPropertyWeaverMsBuildTask.WeavingTask" AssemblyFile="$(SolutionDir)Tools\NotifyPropertyWeaverMsBuildTask.dll" />
<Target AfterTargets="CopyFilesToOutputDirectory" Name="NotifyPropertyWeaver">
<NotifyPropertyWeaverMsBuildTask.WeavingTask TargetPath="$(TargetPath)"/>
<Copy SourceFiles="$(TargetPath)" DestinationFiles="@(IntermediateAssembly)"/>
</Target>
@SimonCropp
SimonCropp / gist:1344356
Created November 7, 2011 06:56
multiport kayak
protected override void OnStart(string[] args)
{
var ports = new [] { 91, 8091 };
foreach (var port in ports)
{
try
{
ListenOnThread(port);
}
catch(Exception exception)