Guest User

Untitled

a guest
Nov 10th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public class Account: IEntity<string>
  2. {
  3. public string Id { get; }
  4. public string Username { get; }
  5. public string Password { get; }
  6.  
  7. public Account(string id, string username, string password)
  8. {
  9. Id = id;
  10. Username = username;
  11. Password = password;
  12. }
  13. }
  14.  
  15. public interface IEntity<out T>
  16. {
  17. T Id { get; }
  18. }
  19.  
  20. public class AccountFactory: IAccountFactory
  21. {
  22. private readonly IHashingService _hashingService;
  23.  
  24. public AccountFactory(IHashingService hashingService)
  25. {
  26. _hashingService = hashingService;
  27. }
  28.  
  29. public Entities.Account Create(string username, string password)
  30. {
  31. var id = IdentityBuilder.Build();
  32. var hashedPassword = _hashingService.HashPassword(password);
  33.  
  34. return new Entities.Account(id, username, hashedPassword);
  35. }
  36. }
Add Comment
Please, Sign In to add comment