public TryResult WithKey(string key, Action <Argument> argumentAction) { if (!keys.ContainsKey(key)) { return(TryResult.Fail()); } var argument = keys[key]; argumentAction(argument); return(TryResult.Pass()); }
public TryResult At(int position, Action <Argument> argumentAction) { if (position < 0 || position >= arguments.Count) { return(TryResult.Fail()); } var argument = arguments[position]; argumentAction(argument); return(TryResult.Pass()); }
public TryResult At(int position, string command, Action argumentAction) { if (position < 0 || position >= arguments.Count) { return(TryResult.Fail()); } var argument = arguments[position]; if (argument.Value != command) { return(TryResult.Fail()); } argumentAction(); return(TryResult.Pass()); }
public TryResult WithTypedKeyOptional <T>(string key, Action <Argument> argumentAction) where T : IConvertible { if (!keys.ContainsKey(key)) { return(TryResult.Pass()); } try { Convert.ChangeType(keys[key].Value, typeof(T)); } catch (InvalidCastException) { return(TryResult.Fail()); } var argument = keys[key]; argumentAction(argument); return(TryResult.Pass()); }