| | 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.InheritedProperties |
| | 7 | | { |
| | 8 | | internal class TextDirectionPropertyParser : PropertyParserBase<InheritedPropertiesDescriptor>, IPropertyParser<Inhe |
| | 9 | | { |
| 1 | 10 | | public TextDirectionPropertyParser(List<Warning> warnings, InheritedPropertiesDescriptor descriptor) : base(warn |
| | 11 | | { |
| 1 | 12 | | } |
| | 13 | |
|
| | 14 | | public void ParseProperty(JProperty property) |
| | 15 | | { |
| 1 | 16 | | string[] allowedValues = { "rtl", "ltr", "auto", "inherit" }; |
| 1 | 17 | | if (property.Value.Type != JTokenType.String) |
| | 18 | | { |
| 0 | 19 | | Warnings.Add(WarningFactory.GetTextDirectionWrongValueWarning(property.Value.ToString())); |
| | 20 | | } |
| | 21 | | else |
| | 22 | | { |
| 1 | 23 | | bool stringInAllowedValues = Array.Exists(allowedValues, element => element == property.Value.ToString() |
| 1 | 24 | | if (!stringInAllowedValues) |
| | 25 | | { |
| 1 | 26 | | Warnings.Add(WarningFactory.GetTextDirectionWrongValueWarning(property.Value.ToString())); |
| 1 | 27 | | Descriptor.textDirection = new AtomicPropertyString("inherit"); |
| | 28 | | } |
| 1 | 29 | | else Descriptor.textDirection = new AtomicPropertyString(property.Value.ToString()); |
| | 30 | | } |
| 1 | 31 | | } |
| | 32 | | } |
| | 33 | | } |