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 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 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 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 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 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
Enumerable.Range(1, 30).Select(num => | |
((Func<string[], string>) | |
(buzz => new string[]{ | |
buzz[((num + 2) % 3) / 2] + | |
buzz[((num + 4) % 5) / 4 * 2], | |
""+num | |
}.First(r => r != "")))(new[] { null, "fizz", "buzz"}) | |
).ToList().ForEach(s => Console.WriteLine(s)); |
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 CustomerModel : ModelBase { | |
private string _customerName; | |
public string CustomerName { | |
get { return _customerName; } | |
set { SetProperty(ref _customerName, value); } | |
} | |
private int _orderCount; | |
public int OrderCount { | |
get { return _orderCount; } |
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
/// <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 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; | |
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
#[user] | |
# name = Your Name | |
# email = youremail@example.com | |
[core] | |
autocrlf = true | |
excludesfile = C:\\Users\\Efrain\\Documents\\gitignore_global.txt | |
editor = 'C:/Program Files/Sublime Text 3/subl.exe' -n -w | |
ignorecase = false | |
[push] | |
default = simple |
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
class Solution: | |
def makeGood(self, s: str) -> str: | |
if len(s) <= 1: | |
return s | |
stack = [] | |
for char in s: | |
if (stack and stack[-1] != char | |
and stack[-1].lower() == char.lower()): |
OlderNewer