ServiceFactory.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Text;
  3. using Renci.SshNet.Common;
  4. using Renci.SshNet.Sftp;
  5. namespace Renci.SshNet
  6. {
  7. /// <summary>
  8. /// Basic factory for creating new services.
  9. /// </summary>
  10. internal partial class ServiceFactory : IServiceFactory
  11. {
  12. /// <summary>
  13. /// Creates a new <see cref="ISession"/> with the specified <see cref="ConnectionInfo"/>.
  14. /// </summary>
  15. /// <param name="connectionInfo">The <see cref="ConnectionInfo"/> to use for creating a new session.</param>
  16. /// <returns>
  17. /// An <see cref="ISession"/> for the specified <see cref="ConnectionInfo"/>.
  18. /// </returns>
  19. /// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <c>null</c>.</exception>
  20. public ISession CreateSession(ConnectionInfo connectionInfo)
  21. {
  22. return new Session(connectionInfo);
  23. }
  24. /// <summary>
  25. /// Creates a new <see cref="ISftpSession"/> in a given <see cref="ISession"/> and with
  26. /// the specified operation timeout and encoding.
  27. /// </summary>
  28. /// <param name="session">The <see cref="ISession"/> to create the <see cref="ISftpSession"/> in.</param>
  29. /// <param name="operationTimeout">The operation timeout.</param>
  30. /// <param name="encoding">The encoding.</param>
  31. /// <returns>
  32. /// An <see cref="ISftpSession"/>.
  33. /// </returns>
  34. public ISftpSession CreateSftpSession(ISession session, TimeSpan operationTimeout, Encoding encoding)
  35. {
  36. return new SftpSession(session, operationTimeout, encoding);
  37. }
  38. /// <summary>
  39. /// Create a new <see cref="PipeStream"/>.
  40. /// </summary>
  41. /// <returns>
  42. /// A <see cref="PipeStream"/>.
  43. /// </returns>
  44. public PipeStream CreatePipeStream()
  45. {
  46. return new PipeStream();
  47. }
  48. }
  49. }