Skip to content

Instantly share code, notes, and snippets.

View jmarnold's full-sized avatar

Josh Arnold jmarnold

View GitHub Profile
public class PartialActionExtensionsConvention : IRegistrationConvention
{
public void Process(Type type, Registry registry)
{
var extensionType = type.FindInterfaceThatCloses(typeof(IPartialActionExtension<>));
if(extensionType == null)
{
return;
}
public class Test
{
public Test()
{
Scan(x =>
{
x.IncludeDirectory("content/scripts");
x.IncludeDirectory("packages");
x.IncludeSubdirectories();
});
@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)
@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;
}
public class ApplicationSetting
{
public string Key { get; set; }
public string Value { get; set; }
}
public void AddAsset(Action<IAddAssetExpression> configure)
{
var assetBuilder = new AssetBuilder(this);
configure(expression);
_assets.add(assetBuilder.Build());
}
public class HelloWorldValidationRegistry : ValidationRegistry
{
public HelloWorldValidationRegistry()
{
AppliesTo
.ToThisAssembly();
Models
.IncludeTypes(t => t.Namespace.StartsWith(typeof(ModelMarker).Namespace))
.Exclude<ModelMarker>();
Rules
.IfProperty(p => p.Name.ToLower().Contains("email"), validate => validate.AsEmail())
.IfProperty(p => p.Name.ToLower().Contains("phone"), validate => validate.AsPhoneNumber());
[TestFixture]
public class UserTester
{
[TestFixtureSetUp]
public void FixtureSetUp()
{
Integrator.Initialize(x => x.AddRegistry<HelloWorldStructureMapRegistry>(), new HelloWorldIntegratorRegistry());
}
[Test]
CommanderFactory.Initialize(facility, registry =>
{
registry
.Applies
.ToThisAssembly();
registry
.Entities
.IncludeType<User>();