Match.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. namespace Renci.SshNet.TestTools.OpenSSH
  2. {
  3. public sealed class Match
  4. {
  5. public Match(string[] users, string[] addresses)
  6. {
  7. Users = users;
  8. Addresses = addresses;
  9. }
  10. public string[] Users { get; }
  11. public string[] Addresses { get; }
  12. public string? AuthenticationMethods { get; set; }
  13. public void WriteTo(TextWriter writer)
  14. {
  15. if (writer is null)
  16. {
  17. throw new ArgumentNullException(nameof(writer));
  18. }
  19. writer.Write("Match ");
  20. if (Users.Length > 0)
  21. {
  22. writer.Write("User ");
  23. for (var i = 0; i < Users.Length; i++)
  24. {
  25. if (i > 0)
  26. {
  27. writer.Write(',');
  28. }
  29. writer.Write(Users[i]);
  30. }
  31. }
  32. if (Addresses.Length > 0)
  33. {
  34. writer.Write("Address ");
  35. for (var i = 0; i < Addresses.Length; i++)
  36. {
  37. if (i > 0)
  38. {
  39. writer.Write(',');
  40. }
  41. writer.Write(Addresses[i]);
  42. }
  43. }
  44. writer.WriteLine();
  45. if (AuthenticationMethods != null)
  46. {
  47. writer.WriteLine(" AuthenticationMethods " + AuthenticationMethods);
  48. }
  49. }
  50. }
  51. }