Skip to content

Instantly share code, notes, and snippets.

@panesofglass
panesofglass / Specification.cs
Created October 26, 2009 16:16
A generic specification base class.
using System;
using System.Linq.Expressions;
namespace Foundation.Specifications
{
/// <summary>
/// Defines an abstract class from which to create conditional specifications.
/// </summary>
/// <typeparam name="T">The type of entity used in the specification.</typeparam>
/// <seealso href="http://ubik.com.au/article/named/implementing_the_specification_pattern_with_linq" />
@panesofglass
panesofglass / SpecificationFactory.cs
Created October 26, 2009 16:17
A factory for creating specifications inline using Expressions.
using System;
using System.Linq.Expressions;
namespace Foundation.Specifications
{
/// <summary>
/// Defines a factory for creating specifications inline.
/// </summary>
public static class SpecificationFactory
{
@panesofglass
panesofglass / EnumerableExtensions.cs
Created November 5, 2009 16:22
ForEach extensions
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Foundation.Collections
{
/// <summary>
/// Adds extension methods to the IEnumerable{T} interface.
/// </summary>
@panesofglass
panesofglass / Tuple.cs
Created November 6, 2009 18:29
A set of Tuple classes for pre-.NET 4.0
namespace Foundation
{
/// <summary>
/// Static extensions for creating tuples.
/// </summary>
public static class Tuple
{
#region methods
/// <summary>
@panesofglass
panesofglass / IView.cs
Created November 12, 2009 17:33
A view interface for WPF and Silverlight
using System.Windows.Controls;
using Foundation.Client.PresentationModels;
namespace Foundation.Client.Views
{
/// <summary>
/// Common interface from which all UI views should inherit.
/// </summary>
/// <remarks>
/// In general, all views will inherit from UserControl, which has uses
@panesofglass
panesofglass / IPresentationModel.cs
Created November 12, 2009 17:36
A presentation model (view model) interface for WPF and Silverlight
using System;
using System.ComponentModel;
using System.Windows.Input;
using Foundation.Client.Views;
namespace Foundation.Client.PresentationModels
{
/// <summary>
/// Common interface for all presentation layer models.
/// </summary>
@panesofglass
panesofglass / RxPingPong.cs
Created December 3, 2009 19:07
Ping Pong Actors with Rx
using System;
using System.Collections.Generic;
using System.Linq;
namespace RxPingPong
{
/// <summary>Simple Ping Pong Actor model using Rx</summary>
/// <remarks>
/// You'll need to install the Reactive Extensions (Rx) for this to work.
/// You can get the installer from <see href="http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx"/>
@panesofglass
panesofglass / CallCC.cs
Created December 4, 2009 05:01
Call/CC in Rx
using System;
using System.Collections.Generic;
using System.Linq;
namespace CallCC
{
/// <summary>An attempt to understand Call/CC in Rx</summary>
class Program
{
static void Main(string[] args)
@panesofglass
panesofglass / CompositePredicate.cs
Created January 20, 2010 16:00
Extensions to Func<T, bool> to allow composing predicate functions.
using System;
namespace Fusion.Foundation.Specifications
{
/// <summary>
/// Adds extensions to allow composing predicates.
/// </summary>
public static class CompositePredicate
{
#region methods
using System;
using MvcContrib;
using Stateless;
namespace StatelessResfulie
{
public class Order
{
public enum Trigger { Self, Retrieve, Receipt, Cancel, Pay, Update }
public enum State { IsReady, Delivered, Unpaid, Cancelled, Paid }