public LocalChannel(DirectoryInfo workingDirectory, ChannelSettings channelSettings)
        {
            _channelSettings = channelSettings ?? throw new ArgumentNullException(nameof(channelSettings));

            _workingDirectory = workingDirectory ?? throw new ArgumentNullException(nameof(channelSettings));

            _channelDirection = ChannelDirectionFactory.Get(channelSettings);

            _source = ChannelHelper.GetSourceOrTarget(_channelSettings, workingDirectory).Item1;

            _target = ChannelHelper.GetSourceOrTarget(_channelSettings, workingDirectory).Item2;
        }
        public SftpChannel(DirectoryInfo workingDirectory, ChannelSettings channelSettings)
        {
            _channelSettings = channelSettings ?? throw new ArgumentNullException(nameof(channelSettings));

            _workingDirectory = workingDirectory ?? throw new ArgumentNullException(nameof(channelSettings));

            _channelDirection = ChannelDirectionFactory.Get(channelSettings);

            _source = string.IsNullOrEmpty(channelSettings.Path) ? throw new ArgumentException(nameof(channelSettings.Path))  :  channelSettings.Path;

            _target = _workingDirectory;

            _connectionInfo = channelSettings.AsConnectionInfo();
        }
示例#3
0
        //separation of concern issue + it validates as well :(
        public static (DirectoryInfo, DirectoryInfo) GetSourceOrTarget(ChannelSettings settings, DirectoryInfo workingDirectory)
        {
            var channelDirection = ChannelDirectionFactory.Get(settings);

            if (channelDirection == ChannelDirection.Inbound)
            {
                return(settings.Path.AsDirectoryInfo().ThrowExceptionIfNullOrDoesntExists(),
                       workingDirectory);
            }
            else
            {
                return(workingDirectory.ThrowExceptionIfNullOrDoesntExists(),
                       settings.Path.AsDirectoryInfo().ThrowExceptionIfNullOrDoesntExists());
            }
        }