Skip to content

Instantly share code, notes, and snippets.

View JeremySkinner's full-sized avatar

Jeremy Skinner JeremySkinner

View GitHub Profile
public abstract class StepBase<T,TProperty, TSelf> : IConfigurable<PropertyRule<T>, TSelf> where TSelf : StepBase<T, TProperty, TSelf> {
...
}
@Html.Grid(Model).Columns(column => {
column.Custom(
@<div>
<em>Hello there</em>
<strong>@item.Name</strong>
</div>
).Named("Custom Column");
})
before_each {
write-host "I will be written before each test is run"
}
when "True is true" {
assert { $true -eq $true }
}
when "True is false, the world may explode" {
assert { $true -eq $false } "True should be false"
public ActionResult Sorting(GridSortOptions sort)
{
// If there's no sort option specifed, then default to sorting on the Name column.
if(string.IsNullOrEmpty(sort.Column)) {
sort = new GridSortOptions { Column = "Name" };
}
ViewData["sort"] = sort;
<%= Html.Grid(Model).Columns(column => {
column.For(x => "<a href='" + Url.Action("Edit") + "'><img src='/content/images/edit.jpg' /></a>").Encode(false);
}) %>
// Should allow for this syntax:
// RuleFor(x => x.Surname).NotNull().WithLocalizedMessage(() => MyResources.SomeResource, x => "foo", x => "bar");
// ...where MyResources.SomeResource has format placeholders
public static IRuleBuilderOptions<T, TProperty> WithLocalizedMessage<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, Expression<Func<string>> resourceSelector, params Func<T, object>[] funcs) {
return rule.Configure(config => {
config.CurrentValidator.ErrorMessageSource = LocalizedStringSource.CreateFromExpression(resourceSelector, new StaticResourceAccessorBuilder());
funcs
.Select(func => new Func<object, object>(x => func((T)x)))
public class PeopleGridModel : GridModel<Person> {
public PeopleGridModel(HtmlHelper html) {
Column.For(x => html.ActionLink("View Details", "Show", new{id = x.Id}));
}
}
<%= Html.Grid(Model).WithModel(new PeopleGridModel(Html)) %>
//MyScript.cs
public class MyScript : Phantom.Core.BuildScript {
Target @default =() => {
System.Console.WriteLine("foo");
};
}
phantom.exe -f:path/to/MyScript.cs
// runs the "default" target from myscript.cs
public interface ICommandHandler<TCommand> {
void Handle(TCommand command);
}
public interface IDispatcher {
void Invoke<TCommand>(TCommand command);
}
public class Dispatcher : IDispatcher {
public void Invoke<TCommand>(TCommand command) {
protected override bool RenderHeader() {
base.RenderHeader();
return !IsDataSourceEmpty();
}
protected override bool ShouldRenderHeader() {
return true;
}