protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { IFtpSession ftpSession = null; FtpConfiguration ftpConfiguration = new FtpConfiguration(Host.Get(context)); ftpConfiguration.Port = Port.Expression == null ? null : (int?)Port.Get(context); ftpConfiguration.UseAnonymousLogin = UseAnonymousLogin; ftpConfiguration.SslProtocols = SslProtocols; ftpConfiguration.ClientCertificatePath = ClientCertificatePath.Get(context); ftpConfiguration.ClientCertificatePassword = ClientCertificatePassword.Get(context); ftpConfiguration.AcceptAllCertificates = AcceptAllCertificates; if (ftpConfiguration.UseAnonymousLogin == false) { ftpConfiguration.Username = Username.Get(context); ftpConfiguration.Password = Password.Get(context); if (string.IsNullOrWhiteSpace(ftpConfiguration.Username)) { throw new ArgumentNullException(Resources.EmptyUsernameException); } if (string.IsNullOrWhiteSpace(ftpConfiguration.Password) && string.IsNullOrWhiteSpace(ftpConfiguration.ClientCertificatePath)) { throw new ArgumentNullException(Resources.NoValidAuthenticationMethod); } } if (UseSftp) { ftpSession = new SftpSession(ftpConfiguration); } else { ftpSession = new FtpSession(ftpConfiguration, FtpsMode); } await ftpSession.OpenAsync(cancellationToken); return((nativeActivityContext) => { if (Body != null) { _ftpSession = ftpSession; nativeActivityContext.ScheduleAction(Body, ftpSession, OnCompleted, OnFaulted); } }); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { IFtpSession ftpSession = null; FtpConfiguration ftpConfiguration = new FtpConfiguration(Host.Get(context)); ftpConfiguration.Port = Port.Expression == null ? null : (int?)Port.Get(context); ftpConfiguration.UseAnonymousLogin = UseAnonymousLogin; ftpConfiguration.ClientCertificatePath = ClientCertificatePath.Get(context); ftpConfiguration.ClientCertificatePassword = ClientCertificatePassword.Get(context); ftpConfiguration.AcceptAllCertificates = AcceptAllCertificates; if (ftpConfiguration.UseAnonymousLogin == false) { ftpConfiguration.Username = Username.Get(context); ftpConfiguration.Password = Password.Get(context); } if (UseSftp) { ftpSession = new SftpSession(ftpConfiguration); } else { ftpSession = new FtpSession(ftpConfiguration, FtpsMode); } await ftpSession.OpenAsync(cancellationToken); return((nativeActivityContext) => { if (Body != null) { _ftpSession = ftpSession; nativeActivityContext.ScheduleAction(Body, ftpSession, OnCompleted, OnFaulted); } }); }