Extensions.NET40.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Sockets;
  5. using System.Text;
  6. namespace Renci.SshNet
  7. {
  8. /// <summary>
  9. /// Collection of different extension method specific for .NET 4.0
  10. /// </summary>
  11. public static partial class Extensions
  12. {
  13. /// <summary>
  14. /// Indicates whether a specified string is null, empty, or consists only of white-space characters.
  15. /// </summary>
  16. /// <param name="value">The string to test.</param>
  17. /// <returns>
  18. /// <c>true</c> if the value parameter is null or System.String.Empty, or if value consists exclusively of white-space characters; otherwise, <c>false</c>.
  19. /// </returns>
  20. internal static bool IsNullOrWhiteSpace(this string value)
  21. {
  22. return string.IsNullOrWhiteSpace(value);
  23. }
  24. internal static bool CanRead(this Socket socket)
  25. {
  26. return socket.Connected && socket.Poll(-1, SelectMode.SelectRead) && socket.Available > 0;
  27. }
  28. internal static bool CanWrite(this Socket socket)
  29. {
  30. return socket.Connected && socket.Poll(-1, SelectMode.SelectWrite);
  31. }
  32. }
  33. }