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); }
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); }