Skip to content

Instantly share code, notes, and snippets.

View jmarnold's full-sized avatar

Josh Arnold jmarnold

View GitHub Profile
@jmarnold
jmarnold / SMBug.cs
Created June 28, 2011 13:58
SM Bug
using System;
using System.Diagnostics;
using System.Linq;
using StructureMap;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
@jmarnold
jmarnold / JsonResponse.cs
Created July 2, 2011 15:16
ActionLess JSON
public class JsonResponse
{
private readonly IList<string> _errors = new List<string>();
public bool Success { get; set; }
public IEnumerable<string> Errors { get { return _errors; } }
public void RegisterError(string error)
{
_errors.Fill(error);
@jmarnold
jmarnold / IContentPart.cs
Created July 4, 2011 17:39
MultipleViews
public interface IContentPart { }
public class TitlePart : IContentPart { // whatever else }
public class BodyPart : IContentPart { // whatever else }
@jmarnold
jmarnold / DefaultPolicy.cs
Created July 9, 2011 21:09
Compositional Patterns: Policies
public class DefaultPolicy : IPolicy
{
public bool Matches()
{
return true;
}
public void Execute()
{
// default behavior
@jmarnold
jmarnold / IStringifier.cs
Created July 12, 2011 04:55
Simplistic Stringification
public interface IStringifier
{
bool Matches(StringifyRequest request);
string Stringify(StringifyRequest request);
}
@jmarnold
jmarnold / ConfigureStringifierExpression.cs
Created July 12, 2011 15:34
Stringification Registry
public class ConfigureStringifierExpression
{
private readonly Func<StringifyRequest, bool> _predicate;
private readonly StringifierModel _model;
public ConfigureStringifierExpression(Func<StringifyRequest, bool> predicate, StringifierModel model)
{
_predicate = predicate;
_model = model;
}
public interface IConfigurationAction
{
void Configure(SemanticModel model);
}
@jmarnold
jmarnold / IModelTypeCoordinator.cs
Created July 29, 2011 06:03 — forked from schotime/gist:1113211
ValidationBehavior<T>
public interface IModelTypeCoordinator
{
IValidationModel FindGetFor(Type postType);
}
@jmarnold
jmarnold / ModelFinder.cs
Created August 19, 2011 19:36
ModelFinder
public class ModelFinder : IModelFinder
{
private readonly BehaviorGraph _graph;
public ModelFinder(BehaviorGraph graph)
{
_graph = graph;
}
public Type FindRelatedModel(Type type)
@jmarnold
jmarnold / routing.js
Created August 29, 2011 17:10
Simple JS DSL example
jBus.routing = new (function() {
function lazy(builder) {
this.builder = builder;
this.buildWith = function(func) {
this.builder = func;
};
this.value = function() {
return this.builder();
};