| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Collections.Generic;
- using Renci.SshNet.Common;
- using Renci.SshNet.Sftp;
- namespace Renci.SshNet.Tests.Common
- {
- internal static class Extensions
- {
- public static string AsString(this IList<ExceptionEventArgs> 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;
- }
- /// <summary>
- /// Creates a deep clone of the current instance.
- /// </summary>
- /// <returns>
- /// A deep clone of the current instance.
- /// </returns>
- internal static SftpFileAttributes Clone(this SftpFileAttributes value)
- {
- Dictionary<string, string> clonedExtensions;
- if (value.Extensions != null)
- {
- clonedExtensions = new Dictionary<string, string>(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);
- }
- }
- }
|