StatePrinting.Configurations.Configuration.TryGetValueConverter C# (CSharp) Метод

TryGetValueConverter() публичный Метод

Find a handler for the type. Handlers are examined in the reverse order of adding and the first match is returned.
public TryGetValueConverter ( Type source, IValueConverter &result ) : bool
source System.Type
result IValueConverter
Результат bool
        public bool TryGetValueConverter(Type source, out IValueConverter result)
        {
            if (!converterLookup.TryGetValue(source, out result))
            {
                result = valueConverters.FirstOrDefault(x => x.CanHandleType(source));
                converterLookup.Add(source, result);
            }
            return result != null;
        }

Usage Example

Пример #1
0
        public void TryFind()
        {
            var config = new Configuration();
            config.Add(new StandardTypesConverter(null));

            IValueConverter h;
            Assert.IsTrue(config.TryGetValueConverter(typeof(decimal), out h));
            Assert.IsTrue(h is StandardTypesConverter);
        }