public static SlashCommandPayload ParseFromFormEncodedData(string formData) { Guard.ThrowIfCheckFails(!string.IsNullOrEmpty(formData), "cannot be null or empty", nameof(formData)); var reader = new FormReader(formData); var commandPayload = new SlashCommandPayload(); var keepReading = true; do { var nextPair = reader.ReadNextPair(); if (nextPair.HasValue) { var propertyInfo = typeof(SlashCommandPayload).GetProperty(nextPair.Value.Key); if (propertyInfo != null) { propertyInfo.SetValue(commandPayload, nextPair.Value.Value); } } else { keepReading = false; } } while (keepReading); return(commandPayload); }
protected virtual Task <KeyValuePair <string, string>?> ReadPair(FormReader reader) { return(Task.FromResult(reader.ReadNextPair())); }