| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | 3 | | using ValidateLib.Metadata.Descriptors; |
| | 4 | | using ValidateLib.Metadata.Properties.AtomicProperties; |
| | 5 | |
|
| | 6 | | namespace ValidateLib.Metadata.PropertyParsers.TopLevelObject |
| | 7 | | { |
| | 8 | | public class TableDirectionPropertyParser : PropertyParserBase<TopLevelObjectDescriptor>, IPropertyParser<TopLevelOb |
| | 9 | | { |
| 1 | 10 | | public TableDirectionPropertyParser(List<Warning> warnings, TopLevelObjectDescriptor descriptor) : base(warnings |
| | 11 | | { |
| 1 | 12 | | } |
| | 13 | |
|
| | 14 | | public void ParseProperty(JProperty property) |
| | 15 | | { |
| 1 | 16 | | string[] allowedValues = { "rtl", "ltr", "auto" }; |
| 1 | 17 | | if (property.Value.Type != JTokenType.String) |
| | 18 | | { |
| 0 | 19 | | Warnings.Add(WarningFactory.GetTableDirectionWrongValueWarning(property.Value.ToString())); |
| 0 | 20 | | Descriptor.tableDirection = new AtomicPropertyString("auto"); |
| | 21 | | } |
| | 22 | | else |
| | 23 | | { |
| 1 | 24 | | bool stringInAllowedValues = Array.Exists(allowedValues, element => element == property.Value.ToString() |
| 1 | 25 | | if (!stringInAllowedValues) |
| | 26 | | { |
| 1 | 27 | | Warnings.Add(WarningFactory.GetTableDirectionWrongValueWarning(property.Value.ToString())); |
| | 28 | | } |
| 0 | 29 | | else Descriptor.tableDirection = new AtomicPropertyString(property.Value.ToString()); |
| | 30 | | } |
| 0 | 31 | | } |
| | 32 | | } |
| | 33 | | } |