Path for FileHelpers.com for handling empty (not provided) Guid values
// Replace constructor in line 53 with this one | |
public FieldNullValueAttribute(Type type, string nullValue) | |
: this(TypeDescriptor.GetConverter(type).ConvertFromString(nullValue)) | |
{ } |
// Unit test to be placed where it's more appropriate | |
[Test] | |
public void RunTimeEmptyGuidProperties() | |
{ | |
var builder = new DelimitedClassBuilder(typeof (EntityWithGuid).Name, "\t"); | |
builder.AddField("Name", typeof (string)); | |
builder.AddField("Id", typeof (Guid)); | |
builder.LastField.FieldNullValue = Guid.Empty; | |
var engine = new FileHelperEngine(builder.CreateRecordClass()) | |
{ | |
Options = {IgnoreFirstLines = 1} | |
}; | |
const string inputValue = @"Name Id | |
first | |
second "; | |
Assert.That(engine.ReadString(inputValue).Length, Is.EqualTo(2)); | |
} | |
public class EntityWithGuid | |
{ | |
public string Name { get; set; } | |
public Guid Id { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment