Beispiel #1
0
        /// <summary>
        ///     Gets an FormatterCache from ether the custom formatter or the global one
        /// </summary>
        public virtual FormatterCache PrepareFormatterCall(Type type,
                                                           string name,
                                                           FormatterArgumentType[] arguments,
                                                           ScopeData scopeData)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = null;
            }

            //call formatters that are given by the Options for this run
            var cache = scopeData.ParserOptions.Formatters.PrepareCallMostMatchingFormatter(type, arguments, name, scopeData.ParserOptions, scopeData);

            if (cache != null)
            {
                //one formatter has returned a valid value so use this one.
                return(cache);
            }

            //all formatters in the options object have rejected the value so try use the global ones
            return(DefaultFormatter.PrepareCallMostMatchingFormatter(type, arguments, name, scopeData.ParserOptions, scopeData));
        }