Skip to content

Commit

Permalink
Tested FtpTransfer
Browse files Browse the repository at this point in the history
Bumped the version
published on NuGet
  • Loading branch information
Val authored and Val committed Sep 4, 2016
1 parent fe8f3d6 commit 7bf0424
Show file tree
Hide file tree
Showing 26 changed files with 326 additions and 298 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace vm.Aspects.FtpTransfer
/// Represents a file list entry in the list of file (Unix or DOS style) coming from the FTP site.
/// </summary>
/// <seealso cref="IEquatable{FileListEntry}" />
public class FileListEntry : IEquatable<FileListEntry>
public class FtpFileListEntry : IEquatable<FtpFileListEntry>
{
/// <summary>
/// Gets or sets a value indicating whether this instance is folder or a file.
Expand Down Expand Up @@ -48,13 +48,13 @@ public class FileListEntry : IEquatable<FileListEntry>
/// </summary>
public string Name { get; set; }

#region IEquatable<StreamDescriptor> Members
#region IEquatable<FtpFileListEntry> Members
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns>
public virtual bool Equals(FileListEntry other)
public virtual bool Equals(FtpFileListEntry other)
{
if (ReferenceEquals(other, null))
return false;
Expand All @@ -78,7 +78,7 @@ public virtual bool Equals(FileListEntry other)
/// <param name="obj">The object to compare with the current object.</param>
/// <returns><see langword="true" /> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <see langword="false" />.</returns>
public override bool Equals(object obj)
=> Equals(obj as FileListEntry);
=> Equals(obj as FtpFileListEntry);

/// <summary>
/// Returns a hash code for this instance.
Expand All @@ -89,45 +89,45 @@ public override int GetHashCode()
var hashCode = Constants.HashInitializer;

hashCode = Constants.HashMultiplier * hashCode + IsFolder.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + AccessRights.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + (AccessRights!=null ? AccessRights.GetHashCode() : 0);
hashCode = Constants.HashMultiplier * hashCode + Number.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + Owner.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + Group.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + (Owner!=null ? Owner.GetHashCode() : 0);
hashCode = Constants.HashMultiplier * hashCode + (Group!=null ? Group.GetHashCode() : 0);
hashCode = Constants.HashMultiplier * hashCode + FileSize.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + Created.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + Name.GetHashCode();
hashCode = Constants.HashMultiplier * hashCode + (Name!=null ? Name.GetHashCode() : 0);

return hashCode;
}

/// <summary>
/// Compares two <see cref="FileListEntry"/> objects.
/// Compares two <see cref="FtpFileListEntry"/> objects.
/// </summary>
/// <param name="left">The left operand.</param>
/// <param name="right">The right operand.</param>
/// <returns>
/// <c>true</c> if the objects are considered to be equal (<see cref="Equals{FileListEntry}"/>);
/// <c>true</c> if the objects are considered to be equal (<see cref="Equals(FtpFileListEntry)"/>);
/// otherwise <c>false</c>.
/// </returns>
public static bool operator ==(
FileListEntry left,
FileListEntry right)
FtpFileListEntry left,
FtpFileListEntry right)
=> ReferenceEquals(left, null)
? ReferenceEquals(right, null)
: left.Equals(right);

/// <summary>
/// Compares two <see cref="FileListEntry"/> objects.
/// Compares two <see cref="FtpFileListEntry"/> objects.
/// </summary>
/// <param name="left">The left operand.</param>
/// <param name="right">The right operand.</param>
/// <returns>
/// <c>true</c> if the objects are not considered to be equal (<see cref="Equals{FileListEntry}"/>);
/// <c>true</c> if the objects are not considered to be equal (<see cref="Equals(FtpFileListEntry)"/>);
/// otherwise <c>false</c>.
/// </returns>
public static bool operator !=(
FileListEntry left,
FileListEntry right)
FtpFileListEntry left,
FtpFileListEntry right)
=> !(left==right);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class FtpParseMSDosListStreams : IFileListParser
/// </summary>
/// <param name="fileListStream">The list streams.</param>
/// <returns>Sequence FileListEntry.</returns>
public IEnumerable<FileListEntry> Parse(
public IEnumerable<FtpFileListEntry> Parse(
Stream fileListStream)
{
var reader = new StreamReader(fileListStream, Encoding.Unicode);
var reader = new StreamReader(fileListStream, Encoding.ASCII);

while (!reader.EndOfStream)
{
Expand All @@ -50,12 +50,12 @@ public IEnumerable<FileListEntry> Parse(
}
#endregion

static FileListEntry StreamDescriptorFactory(Match match)
static FtpFileListEntry StreamDescriptorFactory(Match match)
{
int num;
DateTime dt;

return new FileListEntry
return new FtpFileListEntry
{
IsFolder = !string.IsNullOrWhiteSpace(match.Groups["isDir"].Value),
Name = match.Groups["name"].Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class FtpParseUnixListStreams : IFileListParser

/// <summary>
/// Parses the specified stream returned by the FTP site to the command ls or dir
/// and produces a sequence of <see cref="FileListEntry" />-s.
/// and produces a sequence of <see cref="FtpFileListEntry" />-s.
/// </summary>
/// <param name="fileListStream">The stream whose contents will be parsed to produce the list of entries.</param>
/// <returns>A sequence of <see cref="FileListEntry" />-s</returns>
public IEnumerable<FileListEntry> Parse(
/// <returns>A sequence of <see cref="FtpFileListEntry" />-s</returns>
public IEnumerable<FtpFileListEntry> Parse(
Stream fileListStream)
{
var reader = new StreamReader(fileListStream, Encoding.ASCII);
Expand All @@ -48,12 +48,12 @@ public IEnumerable<FileListEntry> Parse(
}
}

static FileListEntry StreamDescriptorFactory(Match match)
static FtpFileListEntry StreamDescriptorFactory(Match match)
{
int num;
DateTime dt;

return new FileListEntry
return new FtpFileListEntry
{
IsFolder = string.Compare(match.Groups["dir"].Value, "d", StringComparison.OrdinalIgnoreCase) == 0,
AccessRights = match.Groups["access"].Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ public class FtpUserCredentials
/// </summary>
/// <remarks>Needed in case the remote site requires user credentials.</remarks>
/// <value>The user name</value>
public virtual string UserName { get; set; }

/// <summary>
/// The encrypted password part of the credentials if required by the remote site.
/// </summary>
/// <remarks>Needed in case the remote site requires user credentials.</remarks>
/// <value>The encrypted password.</value>
public virtual string Password64 { get; set; }
public string UserName { get; set; }

/// <summary>
/// Gets the password.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ public interface IFileListParser
{
/// <summary>
/// Parses the specified stream returned by the FTP site to the command ls or dir
/// and produces a sequence of <see cref="FileListEntry"/>-s.
/// and produces a sequence of <see cref="FtpFileListEntry"/>-s.
/// </summary>
/// <param name="fileListStream">The stream whose contents will be parsed to produce the list of entries.</param>
/// <returns>A sequence of <see cref="FileListEntry"/>-s</returns>
IEnumerable<FileListEntry> Parse(Stream fileListStream);
/// <returns>A sequence of <see cref="FtpFileListEntry"/>-s</returns>
IEnumerable<FtpFileListEntry> Parse(Stream fileListStream);
}

#region IFileListParser contracts
[ContractClassFor(typeof(IFileListParser))]
abstract class IFileListParserContract : IFileListParser
{
public IEnumerable<FileListEntry> Parse(Stream fileListStream)
public IEnumerable<FtpFileListEntry> Parse(Stream fileListStream)
{
Contract.Requires<ArgumentNullException>(fileListStream != null, nameof(fileListStream));
Contract.Ensures(Contract.Result<IEnumerable<FileListEntry>>() != null);
Contract.Ensures(Contract.Result<IEnumerable<FtpFileListEntry>>() != null);

throw new NotImplementedException();
}
Expand Down
54 changes: 54 additions & 0 deletions Aspects/FtpTransfer/ITransferClientConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;

namespace vm.Aspects.FtpTransfer
{
/// <summary>
/// Represents the configuration properties of the FTP transfer site objects represented by <see cref="ITransferClientConfiguration"/>.
/// Note that the interface inherits from <see cref="ICloneable"/> which should be used by the transfer object to clone the properties internally for multiple use.
/// </summary>
/// <seealso cref="ICloneable" />
public interface ITransferClientConfiguration : ICloneable
{
#region Properties
/// <summary>
/// URL string of the target.
/// </summary>
/// <remarks>This is the URL string of the resource to be downloaded (from) or uploaded (to)</remarks>
/// <value>The URL of the resource.</value>
string Link { get; }

/// <summary>
/// Gets or sets a value that specifies that an SSL connection should be used.
/// </summary>
/// <value>
/// <c>true</c> if SSL is enabled; otherwise, <c>false</c>.
/// </value>
bool EnableSsl { get; }

/// <summary>
/// Gets or sets a value which specifies the data type for file transfers.
/// </summary>
bool UseBinary { get; }

/// <summary>
/// Gets or sets a value indicating whether the control connection to the FTP server is closed after the request completes.
/// </summary>
/// <value>
/// <c>true</c> if keep-alive-s are enabled; otherwise, <c>false</c>.
/// </value>
bool KeepAlive { get; }

/// <summary>
/// The user name part of the credentials if required by the remote site.
/// </summary>
/// <remarks>Needed in case the remote site requires user credentials.</remarks>
/// <value>The user name</value>
string UserName { get; }

/// <summary>
/// Gets the password.
/// </summary>
string Password { get; }
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ namespace vm.Aspects.FtpTransfer
/// <summary>
/// Abstracts a object that can list download and upload files (e.g. from an FTP site).
/// </summary>
[ContractClass(typeof(ITransferFileContract))]
public interface ITransferFile
[ContractClass(typeof(ITransferFilesContract))]
public interface ITransferFiles
{

/// <summary>
/// Lists the files available for receiving at the target (something like dir or ls).
/// </summary>
Expand All @@ -35,7 +34,6 @@ public interface ITransferFile

// -----------------------------------------


/// <summary>
/// Asynchronously lists the files available for receiving at the target (something like dir or ls).
/// </summary>
Expand All @@ -59,8 +57,8 @@ public interface ITransferFile
}

#region ITransferFile contract binding
[ContractClassFor(typeof(ITransferFile))]
abstract class ITransferFileContract : ITransferFile
[ContractClassFor(typeof(ITransferFiles))]
abstract class ITransferFilesContract : ITransferFiles
{
public Stream DownloadFile(string name)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[assembly: AssemblyTitle("vm.Aspects.FtpTransfer")]
[assembly: AssemblyDescription("A set of classes for FTP file transfer.")]
[assembly: AssemblyVersion("1.0.67")]
[assembly: AssemblyFileVersion("1.0.67")]
[assembly: AssemblyInformationalVersion("1.0.67")]
[assembly: AssemblyVersion("1.0.68")]
[assembly: AssemblyFileVersion("1.0.68")]
[assembly: AssemblyInformationalVersion("1.0.68")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.FtpTransfer.Test, " +
Expand Down
Loading

0 comments on commit 7bf0424

Please sign in to comment.