Ejemplo n.º 1
0
        public ReadWithFormatter AddFormatter <T>() where T : IFormatter
        {
            var formatter = new ReadWithFormatter(_inputType, typeof(T));
            var existing  = Readers.FirstOrDefault(x => x.Equals(formatter)) as ReadWithFormatter;

            if (existing != null)
            {
                return(existing);
            }

            Readers.AddToEnd(formatter);

            return(formatter);
        }
Ejemplo n.º 2
0
        public Reader AddReader <T>()
        {
            var readerType = typeof(IReader <>).MakeGenericType(_inputType);

            if (!typeof(T).CanBeCastTo(readerType))
            {
                throw new ArgumentOutOfRangeException("{0} can not be cast to {1}", typeof(T).FullName, readerType.FullName);
            }

            var reader = new Reader(typeof(T));

            Readers.AddToEnd(reader);

            return(reader);
        }