| | 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.DIalect |
| | 7 | | { |
| | 8 | | internal class LineTerminatorsPropertyParser : PropertyParserBase<DialectDescriptor>, IPropertyParser<DialectDescrip |
| | 9 | | { |
| 1 | 10 | | public LineTerminatorsPropertyParser(List<Warning> warnings, DialectDescriptor descriptor) : base(warnings, desc |
| | 11 | | { |
| 1 | 12 | | } |
| | 13 | |
|
| | 14 | | public void ParseProperty(JProperty property) |
| | 15 | | { |
| 1 | 16 | | List<string> lineTerminators = new List<string>(); |
| 1 | 17 | | List<string> defaultValue = new List<string> { "\\r\\n", "\\n" }; |
| 1 | 18 | | if (property.Value.Type == JTokenType.String) |
| 0 | 19 | | lineTerminators.Add(property.Value.ToString()); |
| 1 | 20 | | else if (property.Value.Type == JTokenType.Array) |
| | 21 | | { |
| 1 | 22 | | foreach (var item in property.Value) |
| | 23 | | { |
| 1 | 24 | | if (item.Type != JTokenType.String) |
| | 25 | | { |
| 0 | 26 | | Warnings.Add(WarningFactory.GetStringPropertyWrongValueWarning(property.Value, property.Name, pr |
| 0 | 27 | | Descriptor.lineTerminators = new AtomicPropertyArray<string>(defaultValue); |
| | 28 | | } |
| | 29 | | else |
| | 30 | | { |
| 1 | 31 | | lineTerminators.Add(item.ToString()); |
| | 32 | | } |
| | 33 | | } |
| 1 | 34 | | Descriptor.lineTerminators = new AtomicPropertyArray<string>(lineTerminators); |
| | 35 | | } |
| | 36 | | else |
| 1 | 37 | | Warnings.Add(WarningFactory.GetLineTerminatorsWrongValueWarning(property.Value.ToString(), property.Valu |
| | 38 | |
|
| 1 | 39 | | } |
| | 40 | | } |
| | 41 | | } |