Beispiel #1
0
        /// <summary>
        /// Extracts from a <see cref="ICommandKeywords"/> the value correspondent to the <see cref="KeywordToken"/> and
        /// if the <see cref="KeywordToken"/> has the Parser property set, then, the correspondent <see cref="IValueParser"/> will be used to
        /// parse the value, otherwise, the value will be returned as it is stored in the <see cref="ICommandKeywords"/>.
        /// </summary>
        /// <param name="keywords">the <see cref="ICommandKeywords"/> from which the value must be extracted.</param>
        /// <returns></returns>
        public Object GetValue(ICommandKeyValues keywords)
        {
            if (!keywords.ContainsValue(Name))
            {
                return(null);
            }

            Object value = keywords.GetValue(Name);

            if (Parser != null)
            {
                value = callParser(value, Container);
            }

            return(value);
        }
Beispiel #2
0
        /// <summary>
        /// Extracts from a <see cref="ICommandKeywords"/> the value correspondent to the <see cref="KeywordToken"/> and
        /// if the <see cref="KeywordToken"/> has the Formatter property set, then, the correspondent <see cref="IValueFormatter"/> will be used to
        /// format the value, otherwise, the value will be returned as stored in the <see cref="ICommandKeywords"/>.
        /// </summary>
        /// <param name="keywords">the <see cref="ICommandKeywords"/> from which the value must be extracted.</param>
        /// <returns>the extracted and formatted value (if a formatter is set) if found in the <see cref="ICommandKeywords"/> or null if not found</returns>
        public String FormatValue(ICommandKeyValues keywords)
        {
            if (!keywords.ContainsValue(Name))
            {
                return(null);
            }

            Object value = keywords.GetValue(Name);

            if (Formatter != null)
            {
                value = callFormatter(value, Container);
            }

            if (value != null)
            {
                return(value.ToString());
            }

            return("");
        }