| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | 3 | | using ValidateLib.Metadata.Properties; |
| | 4 | |
|
| | 5 | | namespace ValidateLib.Metadata.Parsers |
| | 6 | | { |
| | 7 | | internal class UriTemplatePropertyParser |
| | 8 | | { |
| 0 | 9 | | public URITemplateProperty? Descriptor { get; set; } |
| 1 | 10 | | public List<Warning> Warnings { get; set; } |
| 1 | 11 | | public UriTemplatePropertyParser(List<Warning> warnings) |
| | 12 | | { |
| 1 | 13 | | Warnings = warnings; |
| 1 | 14 | | } |
| | 15 | | public URITemplateProperty ParseJToken(JToken jToken) |
| | 16 | | { |
| 0 | 17 | | throw new NotImplementedException(); |
| | 18 | | } |
| | 19 | | public URITemplateProperty ParseJToken(JToken jToken, string defaultValue, string propertyName) |
| | 20 | | { |
| 1 | 21 | | if (jToken.Type != JTokenType.String) |
| | 22 | | { |
| 1 | 23 | | Warnings.Add(WarningFactory.GetURITemplateWrongValueWarning(jToken, propertyName)); |
| 1 | 24 | | return new URITemplateProperty(defaultValue); |
| | 25 | | } |
| | 26 | | else |
| | 27 | | { |
| 1 | 28 | | return new URITemplateProperty(jToken.ToString()); |
| | 29 | | } |
| | 30 | | } |
| | 31 | |
|
| | 32 | | } |
| | 33 | | } |