Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ parsable types are using now invariant culture to parse values
- Loading branch information
Showing
10 changed files
with
147 additions
and
87 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,31 @@ | ||
using System; | ||
|
||
namespace SevenDigital.Parsing.XsdToObject | ||
{ | ||
public class ParsableType | ||
{ | ||
private readonly string _parseCallFormat; | ||
|
||
public ParsableType(string xmlTypeName, string netTypeName, Type type) | ||
{ | ||
XmlTypeName = xmlTypeName; | ||
NetTypeName = netTypeName; | ||
_parseCallFormat = FormatParseCall(type); | ||
} | ||
|
||
private string FormatParseCall(Type type) | ||
{ | ||
var formatParseCall = type.GetMethod("Parse", new[] { typeof(string), typeof(IFormatProvider) }) != null | ||
? ".Parse({0}, CultureInfo.InvariantCulture)" | ||
: ".Parse({0})"; | ||
return NetTypeName.TrimEnd('?') + formatParseCall; | ||
} | ||
|
||
public string XmlTypeName { get; private set; } | ||
public string NetTypeName { get; private set; } | ||
public string ConstructParseCall(string value) | ||
{ | ||
return string.Format(_parseCallFormat, value); | ||
} | ||
} | ||
} |
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
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