This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$myDir = Split-Path -Parent $MyInvocation.MyCommand.Path | |
Import-Module "$mydir\posh-hg\posh-hg" | |
Import-Module "$mydir\posh-git\posh-git" | |
function prompt { | |
write-host "$pwd" -NoNewLine -foregroundcolor green | |
$Global:GitStatus = Get-GitStatus | |
Write-GitStatus $GitStatus | |
Write-HgStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestValidator : AbstractValidator<Customer> { | |
public TestValidator() { | |
RuleFor(cust => cust.Orders) | |
.SetCollectionValidator(new OrderValidator()) | |
.IncludeWhere(order => order.Amount > 50); | |
//OR | |
RuleFor(cust => cust.Orders) | |
.SetCollectionValidator(new OrderValidator(), includeWhere: order => order.Amount > 50); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<tbody data-bind="template: 'MyTemplate'></tbody> | |
</table> | |
<script id="MyTemplate" type="x-jquery-tmpl"> | |
{{each(i, row) Rows}} | |
<tr> | |
<td> | |
<select data-bind="options: row.Options, optionsText: 'Text', optionsValue: 'Value'"></select> | |
</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WebMatrix.Data's Query method returns an IEnumerable<dynamic> | |
// While this is great for simple scenarios, if you want to add behaviour to your DB objects | |
// then it can be a pain. Here's a simple wrapper that adds a strongly-typed Query method | |
// This is a simple implementation and could be improved. | |
// Represents a table in the database | |
public class User { | |
public int Id { get; set; } | |
public string Name { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override bool RenderHeader() { | |
base.RenderHeader(); | |
return !IsDataSourceEmpty(); | |
} | |
protected override bool ShouldRenderHeader() { | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= Html.Grid(Model).Columns(column => { | |
column.For(x => "<a href='" + Url.Action("Edit") + "'><img src='/content/images/edit.jpg' /></a>").Encode(false); | |
}) %> |