Skip to content

Instantly share code, notes, and snippets.

@morsdyce
morsdyce / sortHtml.js
Created November 7, 2012 17:14
A function to sort a div element by its data attribute while moving html nodes without any performance hits of cloning or removing and reattaching a node.
function sortTableByColorSets() {
// store an empty object to contain all colors
var holdingCell = {};
// loop over the colors in the predfined colors array.
for (var color in colors) {
// get the color value and create a stub for it in the object. e.g object.colorname
colorValue = colors[color];
<component id="FormsAuthenticationService" lifestyle="PerWebRequest" service="ExampleProject1.Services.Interfaces.IFormsAuthenticationService, ExampleProject1" type="ExampleProject1.Services.FormsAuthenticationService, ExampleProject1"></component>
<component id="MembershipService" lifestyle="PerWebRequest" service="ExampleProject1.Services.Interfaces.IMembershipService, ExampleProject1" type="ExampleProject1.Services.MembershipService, ExampleProject1"></component>
<add namespace="ExampleProject1.Models.Account" />
<add namespace="ExampleProject1.Models.Account.Validation" />
@morsdyce
morsdyce / example24.cs
Created November 3, 2012 09:38
example 24
public class AccountController : Controller
{
private readonly IFormsAuthenticationService formsService;
private readonly IMembershipService membershipService;
public AccountController(IFormsAuthenticationService formsService, IMembershipService membershipService)
{
this.formsService = formsService;
this.membershipService = membershipService;
}
public class MembershipService : IMembershipService
{
private readonly MembershipProvider _provider;
public MembershipService()
: this(null)
{
}
public MembershipService(MembershipProvider provider)
public class FormsAuthenticationService : IFormsAuthenticationService
{
public void SignIn(string userName, bool createPersistentCookie)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
}
public void SignOut()
public interface IMembershipService
{
int MinPasswordLength { get; }
bool ValidateUser(string userName, string password);
MembershipCreateStatus CreateUser(string userName, string password, string email);
bool ChangePassword(string userName, string oldPassword, string newPassword);
}
public interface IFormsAuthenticationService
{
void SignIn(string userName, bool createPersistentCookie);
void SignOut();
}
[PropertiesMustMatch("Password", "ConfirmPassword", ErrorMessage = "The password and confirmation password do not match.")]
public class RegisterModel
{
[Required]
[DisplayName("User name")]
public string UserName { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
[DisplayName("Email address")]
public class LogOnModel
{
[Required]
[DisplayName("User name")]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[DisplayName("Password")]
public string Password { get; set; }