Esempio n. 1
0
        /// <summary>
        /// Return the first string selected from a MessageContext
        /// </summary>
        /// <param name="selector"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string SelectString(this DataSelector selector, MessageContext context)
        {
            var stringTask = selector.SelectStringAsync(context);

            stringTask.Wait();

            return(stringTask.Result);
        }
Esempio n. 2
0
        /// <summary>
        /// Attemt to return the first int selected from a MessageContext
        /// </summary>
        /// <param name="selector"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async static Task <(bool Parsed, int Value)> TrySelectIntAsync(this DataSelector selector, MessageContext context)
        {
            string val = await selector.SelectStringAsync(context);

            if (String.IsNullOrWhiteSpace(val))
            {
                return(false, 0);
            }

            if (int.TryParse(val, out int result))
            {
                return(true, result);
            }
            else
            {
                return(false, 0);
            }
        }