UserCollection.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. namespace SMBLibrary.Server
  11. {
  12. public class UserCollection : List<User>
  13. {
  14. public void Add(string accountName, string password)
  15. {
  16. Add(new User(accountName, password));
  17. }
  18. public int IndexOf(string accountName)
  19. {
  20. for (int index = 0; index < this.Count; index++)
  21. {
  22. if (string.Equals(this[index].AccountName, accountName, StringComparison.InvariantCultureIgnoreCase))
  23. {
  24. return index;
  25. }
  26. }
  27. return -1;
  28. }
  29. public List<string> ListUsers()
  30. {
  31. List<string> result = new List<string>();
  32. foreach (User user in this)
  33. {
  34. result.Add(user.AccountName);
  35. }
  36. return result;
  37. }
  38. }
  39. }