Skip to content

Instantly share code, notes, and snippets.

View jmarnold's full-sized avatar

Josh Arnold jmarnold

View GitHub Profile
Rules
.IfProperty(p => p.Name.ToLower().Contains("email"), validate => validate.AsEmail())
.IfProperty(p => p.Name.ToLower().Contains("phone"), validate => validate.AsPhoneNumber());
public class HelloWorldValidationRegistry : ValidationRegistry
{
public HelloWorldValidationRegistry()
{
AppliesTo
.ToThisAssembly();
Models
.IncludeTypes(t => t.Namespace.StartsWith(typeof(ModelMarker).Namespace))
.Exclude<ModelMarker>();
public void AddAsset(Action<IAddAssetExpression> configure)
{
var assetBuilder = new AssetBuilder(this);
configure(expression);
_assets.add(assetBuilder.Build());
}
public class ApplicationSetting
{
public string Key { get; set; }
public string Value { get; set; }
}
@jmarnold
jmarnold / Attributes.cs
Created October 20, 2010 18:40
Simple reusable create entity action call example
// metadata for finding models
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public abstract class DecoratorAttribute : Attribute
{
private readonly Type _entityType;
protected DecoratorAttribute(Type entityType)
{
_entityType = entityType;
}
@jmarnold
jmarnold / DomElement.cs
Created October 26, 2010 19:22
WatiN: jQuery Style
public class DomElement : DynamicObject
{
private readonly object _inner;
public DomElement(object inner)
{
_inner = inner;
}
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
public class Test
{
public Test()
{
Scan(x =>
{
x.IncludeDirectory("content/scripts");
x.IncludeDirectory("packages");
x.IncludeSubdirectories();
});
public class PartialActionExtensionsConvention : IRegistrationConvention
{
public void Process(Type type, Registry registry)
{
var extensionType = type.FindInterfaceThatCloses(typeof(IPartialActionExtension<>));
if(extensionType == null)
{
return;
}
public class OrderProcessingModule
{
public void Process(OrderStatusMessage orderStatusMessage)
{
string connectionString = ConfigurationManager.ConnectionStrings["Main"].ConnectionString;
Order order = null;
using(var connection = new SqlConnection(connectionString))
{
order = FetchData(orderStatusMessage, connection);
[Test]
public void should_return_single_view_token_matched_on_policy_criteria()
{
_descriptor.Templates.Add("Projects\\Dashboard.spark");
_descriptor.Templates.Add("Shared\\Application.spark");
var descriptor2 = newDescriptor();
descriptor2.Templates.Add("Projects\\StoryMap.spark");
descriptor2.Templates.Add("Shared\\Application.spark");
_token.Descriptors.Add(descriptor2);