-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to use a custom property name mapper
Fixes #19
- Loading branch information
Showing
12 changed files
with
202 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using SpecFlow.Assist.Dynamic.PropertyNameMapping; | ||
|
||
namespace SpecFlow.Assist.Dynamic | ||
{ | ||
public class Options | ||
{ | ||
public Options() | ||
{ | ||
this.DoTypeConversion = true; | ||
this.PropertyNameMapper = new DefaultPropertyNameMapper(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether types should be converted | ||
/// according to conventions described in https://github.com/marcusoftnet/SpecFlow.Assist.Dynamic/wiki/Conversion-conventions#property-type-conversions | ||
/// </summary> | ||
/// <value><c>true</c> if types should be converted; otherwise, <c>false</c>.</value> | ||
public bool DoTypeConversion { get; set; } | ||
|
||
public IPropertyNameMapper PropertyNameMapper { get; set; } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
SpecFlow.Assist.Dynamic/PropertyNameMapping/DefaultPropertyNameMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace SpecFlow.Assist.Dynamic.PropertyNameMapping | ||
{ | ||
public class DefaultPropertyNameMapper : IPropertyNameMapper | ||
{ | ||
public string Map(string header) | ||
{ | ||
var words = header.Split(' '); | ||
var propName = words[0]; // leave the first word as is, since it might be correct cased... | ||
|
||
for (var i = 1; i < words.Length; i++) | ||
{ | ||
var s = words[i]; | ||
if (s.Length > 0) | ||
{ | ||
propName += s[0].ToString().ToUpperInvariant() + | ||
s.Substring(1).ToLowerInvariant(); | ||
} | ||
} | ||
|
||
return propName; | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
SpecFlow.Assist.Dynamic/PropertyNameMapping/IPropertyNameMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SpecFlow.Assist.Dynamic.PropertyNameMapping | ||
{ | ||
public interface IPropertyNameMapper | ||
{ | ||
string Map(string header); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.