2
0

MatchFormatter.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. namespace Renci.SshNet.TestTools.OpenSSH.Formatters
  2. {
  3. internal sealed class MatchFormatter
  4. {
  5. public string Format(Match match)
  6. {
  7. using (var writer = new StringWriter())
  8. {
  9. Format(match, writer);
  10. return writer.ToString();
  11. }
  12. }
  13. public void Format(Match match, TextWriter writer)
  14. {
  15. writer.Write("Match ");
  16. if (match.Users.Length > 0)
  17. {
  18. writer.Write("User ");
  19. for (var i = 0; i < match.Users.Length; i++)
  20. {
  21. if (i > 0)
  22. {
  23. writer.Write(',');
  24. }
  25. writer.Write(match.Users[i]);
  26. }
  27. }
  28. if (match.Addresses.Length > 0)
  29. {
  30. writer.Write("Address ");
  31. for (var i = 0; i < match.Addresses.Length; i++)
  32. {
  33. if (i > 0)
  34. {
  35. writer.Write(',');
  36. }
  37. writer.Write(match.Addresses[i]);
  38. }
  39. }
  40. writer.WriteLine();
  41. if (match.AuthenticationMethods != null)
  42. {
  43. writer.WriteLine(" AuthenticationMethods " + match.AuthenticationMethods);
  44. }
  45. }
  46. }
  47. }