/// <summary> /// Initializes a new instance of the <see cref="CsvContext"/> class. /// </summary> /// <param name="reader">The reader.</param> public CsvContext(IReader reader) { Reader = reader; Parser = reader.Parser; Configuration = reader.Configuration as CsvConfiguration ?? throw new InvalidOperationException($"{nameof(IReader)}.{nameof(IReader.Configuration)} must be of type {nameof(CsvConfiguration)} to be used in the context."); Maps = new ClassMapCollection(this); }
public void GetChildMapWhenParentIsMappedBeforeIt() { var parentMap = new ParentMap(); var childMap = new ChildMap(); var c = new ClassMapCollection(); c.Add(parentMap); c.Add(childMap); var map = c[typeof(Child)]; Assert.AreEqual(childMap, map); }
public void GetChildMapWhenParentIsMappedBeforeIt() { var parentMap = new ParentMap(); var childMap = new ChildMap(); var c = new ClassMapCollection(new CsvHelper.Configuration.CsvConfiguration(CultureInfo.InvariantCulture)); c.Add(parentMap); c.Add(childMap); var map = c[typeof(Child)]; Assert.AreEqual(childMap, map); }
/// <summary> /// Initializes a new instance of the <see cref="CsvContext"/> class. /// </summary> /// <param name="configuration">The configuration.</param> public CsvContext(CsvConfiguration configuration) { Configuration = configuration; Maps = new ClassMapCollection(this); }