Beispiel #1
0
        private static IObjectFormatter <T> ScanForObjectFormatter <T>(Type type)
        {
            if (_objectFormatterProviders != null)
            {
                foreach (var objectFormatter2 in _objectFormatterProviders)
                {
                    if ((type == objectFormatter2.Key) || (type.IsSubclassOf(objectFormatter2.Key)))
                    {
                        return((IObjectFormatter <T>)objectFormatter2.Value);
                    }
                }
            }
            Type key;
            IObjectFormatter <T> objectFormatter;

            if (FormatterEx.TryScanForObjectFormatter <T>(out key, out objectFormatter))
            {
                RegisterObjectFormatter(key, objectFormatter);
                return(objectFormatter);
            }
            return(null);
        }
Beispiel #2
0
        private static IValueFormatter <T> ScanForValueFormatter <T>(Type type)
        {
            if (_valueFormatterProviders != null)
            {
                foreach (var valueFormatter2 in _valueFormatterProviders)
                {
                    if ((type == valueFormatter2.Key) || (type.IsSubclassOf(valueFormatter2.Key)))
                    {
                        return((IValueFormatter <T>)valueFormatter2.Value);
                    }
                }
            }
            Type key;
            IValueFormatter <T> valueFormatter;

            if (FormatterEx.TryScanForValueFormatter <T>(out key, out valueFormatter))
            {
                RegisterValueFormatter(key, valueFormatter);
                return(valueFormatter);
            }
            return(null);
        }