This file contains hidden or 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 MvcRegistry : Registry | |
{ | |
public MvcRegistry() { | |
For<BundleCollection>().Use(BundleTable.Bundles); | |
For<RouteCollection>().Use(RouteTable.Routes); | |
For<IIdentity>().Use(() => HttpContext.Current.User.Identity); | |
For<HttpSessionStateBase>() | |
.Use(() => new HttpSessionStateWrapper(HttpContext.Current.Session)); | |
For<HttpContextBase>() | |
.Use(() => new HttpContextWrapper(HttpContext.Current)); |
This file contains hidden or 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 ModelStateValidationAttribute : ActionFilterAttribute, IExceptionFilter | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) { | |
if(filterContext.HttpContext.Request.IsAjaxRequest()) | |
return; | |
var modelIsValid = filterContext.Controller.ViewData.ModelState.IsValid; | |
if(!modelIsValid) { | |
filterContext.Result = new ViewResult() { |
This file contains hidden or 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
/// <summary> | |
/// http://stackoverflow.com/questions/14005773/use-asp-net-mvc-validation-with-jquery-ajax | |
/// </summary> | |
public class ValidateAjaxAttribute : ActionFilterAttribute, IExceptionFilter | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) { | |
if(!filterContext.HttpContext.Request.IsAjaxRequest()) { | |
return; | |
} |
This file contains hidden or 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 FormsAuthenticationService : IFormsAuthenticationService | |
{ | |
private readonly HttpContextBase _context; | |
public FormsAuthenticationService(HttpContextBase context) { | |
_context = context; | |
} | |
public void SignIn(string userName, bool createPersistentCookie, IEnumerable<string> roles = null) { | |
string roleList = string.Empty; |
This file contains hidden or 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 CurrentUser : ICurrentUser { | |
private readonly IIdentity _identity; | |
private readonly HttpSessionStateBase _session; | |
private readonly UserInfoService _service; | |
private IUserInfo _user; | |
public CurrentUser(IIdentity identity, HttpSessionStateBase session, UserInfoService service) { | |
_identity = identity; | |
_session = session; |
This file contains hidden or 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
using StringHelpers; | |
using NUnit.Framework; | |
namespace olakease.Tests { | |
[TestFixture] | |
public class SuperTest { | |
[Test] | |
public void NullObjectShouldNotThrowException() { | |
object obj = null; | |
NewerOlder