| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | 3 | | using ValidateLib.Metadata.Properties; |
| | 4 | | using ValidateLib.UtilityClasses; |
| | 5 | |
|
| | 6 | | namespace ValidateLib.Metadata.Parsers |
| | 7 | | { |
| | 8 | | public class LinkPropertyParser |
| | 9 | | { |
| 0 | 10 | | public LinkProperty? Descriptor { get; set; } |
| 1 | 11 | | public List<Warning> Warnings { get; set; } |
| 0 | 12 | | public LinkPropertyParser(LinkProperty descriptor, List<Warning> warnings) |
| | 13 | | { |
| 0 | 14 | | Descriptor = descriptor; |
| 0 | 15 | | Warnings = warnings; |
| 0 | 16 | | } |
| 1 | 17 | | public LinkPropertyParser(List<Warning> warnings) |
| | 18 | | { |
| 1 | 19 | | Warnings = warnings; |
| 1 | 20 | | } |
| | 21 | |
|
| | 22 | | public LinkProperty? ParseJToken(JToken jToken, string propertyName) |
| | 23 | | { |
| 1 | 24 | | if (jToken.Type != JTokenType.String) |
| | 25 | | { |
| 1 | 26 | | Warnings.Add(WarningFactory.GetLinkPropertyWrongValueWarning(jToken, propertyName, jToken.Type.ToString( |
| 1 | 27 | | return null; |
| | 28 | | } |
| | 29 | | else |
| | 30 | | { |
| 1 | 31 | | if (!IriUtilityClass.IsAbsoluteUrl(jToken.ToString())) |
| | 32 | | { |
| 0 | 33 | | Warnings.Add(WarningFactory.GetLinkPropertyNotAbsoluteWarning(jToken, propertyName)); |
| 0 | 34 | | return null; |
| | 35 | | } |
| 1 | 36 | | else return new LinkProperty(jToken.ToString()); |
| | 37 | | } |
| | 38 | | } |
| | 39 | | } |
| | 40 | | } |