RoboZhando/CommandNext/CommandQuery.cs
/// <summary>
/// Converts a argument to the specific type. Will not throw "KeyNotFound".
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
Converts a argument to the specific type. Will not throw "KeyNotFound".
Converts a argument to the specific type . Will not throw " KeyNotFound " .
public async Task<Optional<T>> GetOptionalArgumentAsync<T>(string key)
        {
            try
            {
                T value = await ConvertArgumentAsync<T>(key);
                return Optional.FromValue<T>(value);
            }
            catch (KeyNotFoundException) { }
            catch (ArgumentNullException e) { throw new ArgumentNullException(key, e.Message); }
            catch (ArgumentException e) { throw new ArgumentException(e.Message, key, e); }
            return Optional.FromNoValue<T>();
        }
public async Task < Optional < T > > GetOptionalArgumentAsync < T > ( string key ) { try { T value = await ConvertArgumentAsync < T > ( key ) ; return Optional . FromValue < T > ( value ) ; } catch ( KeyNotFoundException ) { } catch ( ArgumentNullException e ) { throw new ArgumentNullException ( key , e . Message ) ; } catch ( ArgumentException e ) { throw new ArgumentException ( e . Message , key , e ) ; } return Optional . FromNoValue < T > ( ) ; }
Converts a argument to the specific type.
Converts a argument to the specific type .
None
key
string
None
typeparam
None