Skip to content

Instantly share code, notes, and snippets.

@donbing
Created March 8, 2014 12:33
Show Gist options
  • Save donbing/9429867 to your computer and use it in GitHub Desktop.
Save donbing/9429867 to your computer and use it in GitHub Desktop.
public class Unregistered : ITennantRegistration
{
public ITennantRegistration Regsister()
{
return new Registered();
}
}
public class Registered : ITennantRegistration
{
}
public class Tennant
{
protected ITennantRegistration registration;
public Tennant()
{
this.registration = new Unregistered();
}
public void Register()
{
var reg = registration as Unregistered;
if(reg!=null)
registration = new Registered();
}
public void AddUserAccount(string name, string password)
{
var reg = registration as Registered;
if (reg != null)
this.User = new User(reg, name, password);
}
bool canRegister()
{
return true;// check invariant here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment