using System.Collections.Generic; using Renci.SshNet.Common; using System; using Renci.SshNet.Sftp; namespace Renci.SshNet.Tests.Common { internal static class Extensions { public static string AsString(this IList exceptionEvents) { if (exceptionEvents.Count == 0) { return string.Empty; } var reportedExceptions = string.Empty; foreach (var exceptionEvent in exceptionEvents) { reportedExceptions += exceptionEvent.Exception.ToString(); } return reportedExceptions; } public static byte[] Copy(this byte[] buffer) { var copy = new byte[buffer.Length]; Buffer.BlockCopy(buffer, 0, copy, 0, buffer.Length); return copy; } /// /// Creates a deep clone of the current instance. /// /// /// A deep clone of the current instance. /// internal static SftpFileAttributes Clone(this SftpFileAttributes value) { Dictionary clonedExtensions; if (value.Extensions != null) { clonedExtensions = new Dictionary(value.Extensions.Count); foreach (var entry in value.Extensions) { clonedExtensions.Add(entry.Key, entry.Value); } } else { clonedExtensions = null; } return new SftpFileAttributes(value.LastAccessTimeUtc, value.LastWriteTimeUtc, value.Size, value.UserId, value.GroupId, value.Permissions, clonedExtensions); } } }