Skip to content

Instantly share code, notes, and snippets.

View mxmissile's full-sized avatar
🎯
Focusing

Travis mxmissile

🎯
Focusing
View GitHub Profile
public object GetService(Type serviceType)
{
try
{
return container.Resolve(serviceType);
}
catch
{
return null;
}
@mxmissile
mxmissile / gist:826264
Created February 14, 2011 18:03
ActionButton
public static MvcHtmlString ActionButton<T>(this HtmlHelper helper, Expression<Action<T>> action, string text) where T : Controller
{
return ActionButton(helper, action, text, null);
}
public static MvcHtmlString ActionButton<T>(this HtmlHelper helper, Expression<Action<T>> action, string text, object htmlAttributes) where T : Controller
{
var routing = ExpressionHelper.GetRouteValuesFromExpression(action);
var vpd = helper.RouteCollection.GetVirtualPath(helper.ViewContext.RequestContext, routing);
@mxmissile
mxmissile / gist:1206822
Created September 9, 2011 17:31
Attach A Behavior Correctly?
Policies.EnrichCallsWith<UnitOfWorkActionBehavior>(
x => x.HandlerType.Name.EndsWith("Controller"));
@mxmissile
mxmissile / gist:1233418
Created September 21, 2011 21:48
Editor Html Convention
public class InputWrapperConvention : HtmlConventionRegistry
{
public InputWrapperConvention()
{
Editors.Always.Modify(h => h.WrapWith("div").AddClass("editor-field"));
}
}
//Added in the Registry
$('input:checkbox').each(function () {
if($(this).attr('disabled') != 'disabled')
this.checked = 'checked';
});
@mxmissile
mxmissile / gist:1237587
Created September 23, 2011 15:03
TextBox EditorTemplate
@model string
@{
Layout = "_Layout.cshtml";
}
@Html.TextBoxFor(x => x)
@mxmissile
mxmissile / gist:1237595
Created September 23, 2011 15:05
_Layout.cshtml
<div class="editor-label">
@Html.LabelFor(x => x)
</div>
<div class="editor-field">
@RenderBody()
@if (ViewData.ModelMetadata.IsRequired)
{
<text><span class="required">*</span></text>
}
@Html.ValidationMessageFor(x => x)
@mxmissile
mxmissile / gist:1748852
Created February 6, 2012 01:41
SadConsole Extensions
public static void DrawRectangle(this CellSurface con, Rectangle rect,CellAppearance appearance)
{
if (rect.Width > 0)
{
con.DrawHorizontalLine(rect.Left, rect.Top, rect.Width, appearance);
con.DrawHorizontalLine(rect.Left, rect.Bottom, rect.Width, appearance);
}
if (rect.Width < 0)
{
public ConfigureFubuMVC()
{
// This line turns on the basic diagnostics and request tracing
IncludeDiagnostics(true);
// All public methods from concrete classes ending in "Controller"
// in this assembly are assumed to be action methods
Actions.IncludeClassesSuffixedWithController();
// Policies
@model Fubinator.App.Controllers.IndexViewModel
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
@Model.Message