The code to achieve this won't be hard, but you will have to write everything from scratch as I don't believe there is anything like that already implemented.
To start, please rewrite your classes so that they are using properties:
public class MyClass
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
public string Prop3 { get; set; }
}
Now start creating your configuration class (take it more like a direction, there will be a lot of code in the end):
// Config class
// In real life, you don't want to use static class and method, instead, use injection
public static class Configuration<TEntity>
{
public static PropertyConfigurationBuilder<TEntity, TProperty> Property<TProperty>(Expression<Func<TEntity, TProperty>> propertyExpression)
{
return new PropertyConfigurationBuilder<TEntity, TProperty>(propertyExpression);
}
}
And finally a builder class for syntax chaining:
public class PropertyConfigurationBuilder<TEntity, TProperty>
{
private Expression<Func<TEntity, TProperty>> _propertyExpression;
public PropertyConfigurationBuilder(Expression<Func<TEntity, TProperty>> propertyExpression)
{
_propertyExpression = propertyExpression;
}
public void HasCell(string cell)
{
// Do actuall logic with the Excel sheet here
// To do this, you actually need to access it, so you probably need to inject reference to the actuall sheet
// You also probably don't want to return 'void' but some other builder so you chain your syntax same way Entity Framework does it
}
}
With these simple code snippets, you should be able to use the syntax you want:
public class Usage
{
public void Map()
{
Configuration<MyClass>.Property(e => e.Prop1).HasCell("A2");
}
}
This should be a good starting point for you. I would like to help you further but I am not sure what parts of the implementation you find challenging and there is quite a lot of code and topics to cover.
Feel free to ask further!