Skip to content

Instantly share code, notes, and snippets.

View MrBretticus's full-sized avatar

Brett Errington MrBretticus

View GitHub Profile
@MrBretticus
MrBretticus / LambdaExtensions.cs
Created June 21, 2012 09:11
Extension method to convert lambda property getter expression to a property setter delegate
public static class ExpressionExtensions
{
/// <summary>
/// Converts a lambda property getter expression to a property setter delegate.
/// For example: "o => o.MyProperty" to "o => o.MyProperty = newValue"
/// </summary>
public static Action<TProperty> ConvertGetterToSetter<TObject, TProperty>(this Expression<Func<TObject, TProperty>> expression, TObject o) {
var property = ((MemberExpression)expression.Body).Member as PropertyInfo;
Guard.Against(property == null, "Expression is not a property getter");
@MrBretticus
MrBretticus / gist:1923936
Created February 27, 2012 13:56
What I learnt, or my notes, from "In The Brain of Greg Young: CQRS and Event Sourcing - the Business Perspective"
Notes based on Greg Young's business perspective presentation
http://skillsmatter.com/podcast/agile-testing/greg-young-cqrs-event-sourcing-the-business-perspective
With a standard structural model we make assumptions of what the business may or may not want in the future. How can we presume to know what to track and what to discard.
CQRS/ES benefits:
* Captures behaviour explicitly, events carry the intent of users.
* We can derive any possible model about data that may be required.
* Allows domain experts and users to look at today in any way they may want to.
@MrBretticus
MrBretticus / SimpleRestfulieCall.cs
Created January 25, 2012 08:29
C# example of using the Restfulie .NET client
// NOTE: ripped from https://github.com/caelum/restfulie/wiki/csharp_short_samples
//retrieves the resource through GET: the entry point
dynamic order = Restfulie.At(resourceURI).Get();
Console.WriteLine("the order price is " + order.Price);
Console.WriteLine("The order product is" + order.Product);
// Executing a state transition:
order.Pay();