private FixedLengthSchemaInjector getSchemaInjector() { var injector = new FixedLengthSchemaInjector(); injector.When(values => values.Length == 2).Use(getHeaderSchema()); injector.When(values => values.Length == 3).Use(getFooterSchema()); injector.WithDefault(getRecordSchema()); return(injector); }
/// <summary> /// Gets a typed writer for writing the objects to the file. /// </summary> /// <param name="writer">The writer to use.</param> /// <param name="options">The separate value options to use.</param> /// <returns>The typed writer.</returns> public ITypedWriter <object> GetWriter(TextWriter writer, FixedLengthOptions options = null) { var injector = new FixedLengthSchemaInjector(); var valueWriter = new FixedLengthWriter(writer, injector, options); var multiWriter = new MultiplexingTypedWriter(valueWriter, this); foreach (var matcher in matchers) { injector.When((values) => matcher.IsMatch).Use(matcher.TypeMapper.GetSchema()); } if (defaultMatcher != nonMatcher) { injector.WithDefault(defaultMatcher.TypeMapper.GetSchema()); } return(multiWriter); }