Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 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());
            }
        }