Example #1
0
 public object Any(EnumRequest request)
 {
     return(new EnumResponse {
         Operator = request.Operator
     });
 }
 public object Any(EnumRequest request)
 {
     return new EnumResponse { Operator = request.Operator };
 }
Example #3
0
 private FtpRequest GetBaseRequest(EnumRequest ftpRequest, string args = null)
 {
     switch (ftpRequest)
     {
         case EnumRequest.GetCurrentPath: return new FtpRequest(FtpConstants.COMMAND_PWD, null);
         case EnumRequest.GetFeature: return new FtpRequest(FtpConstants.COMMAND_FEAT, null);
         case EnumRequest.GetList: return new FtpRequest(FtpConstants.COMMAND_NLST, null);
         case EnumRequest.GetSystem: return new FtpRequest(FtpConstants.COMMAND_SYST, null);
         case EnumRequest.SetType: return new FtpRequest(FtpConstants.COMMAND_TYPE, args);
         case EnumRequest.PassiveMode: return new FtpRequest(FtpConstants.COMMAND_PASV, null);
         case EnumRequest.SetPassword: return new FtpRequest(FtpConstants.COMMAND_PASS, args);
         case EnumRequest.SetUser: return new FtpRequest(FtpConstants.COMMAND_USER, args);
         case EnumRequest.SetPort: return new FtpRequest(FtpConstants.COMMAND_PORT, args);
         case EnumRequest.ChangeDirectory: return new FtpRequest(FtpConstants.COMMAND_CWD, args);
         case EnumRequest.GetFile: return new FtpRequest(FtpConstants.COMMAND_RETR, args);
         case EnumRequest.UploadFile: return new FtpRequest(FtpConstants.COMMAND_STOR, args);
         default: throw new Exception(FtpConstants.MESSAGE_FAIL_CREATE_REQUEST);
     }
 }
Example #4
0
        /// <summary>
        /// Write the command on the socket output stream and read the response.
        /// </summary>
        /// <param name="request">Enumeration item representing the command to send.</param>
        /// <param name="args">Values to send with the command.</param>
        /// <returns>FtpResponse containing what has been on the socket.</returns>
        private async Task<FtpResponse> ExecuteRequest(EnumRequest request, string args = null)
        {
            FtpRequest baseRequest = GetBaseRequest(request, args);
            string result = await WriteOnSocket(baseRequest.Command);
            if (!result.Equals(FtpConstants.OK))
                return new FtpResponse(FtpConstants.CODE_FAIL_WRITE_ON_SOCKET, "Fail to write on socket. " + result);

            if (request == EnumRequest.GetList || request == EnumRequest.GetFile)
                return await WaitForTransferComplete();

            return await ReadSocket();
        }
 public object Any(EnumRequest request) => new EnumResponse
 {
     Operator = request.Operator
 };
 public Task <MyEnum> GetByEnumFromRequest([FromQuery] EnumRequest myEnumRequest) => Task.FromResult(myEnumRequest.MyEnum);