| | | 1 | | using Newtonsoft.Json.Linq; |
| | | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | | 3 | | using ValidateLib.Metadata.Descriptors; |
| | | 4 | | using ValidateLib.Metadata.Properties; |
| | | 5 | | using ValidateLib.Metadata.Validators; |
| | | 6 | | |
| | | 7 | | namespace ValidateLib.Metadata.PropertyParsers.Schema |
| | | 8 | | { |
| | | 9 | | internal class RowTitlesPropertyParser : PropertyParserBase<SchemaDescriptor>, IPropertyParser<SchemaDescriptor> |
| | | 10 | | { |
| | 1 | 11 | | public RowTitlesPropertyParser(List<Warning> warnings, SchemaDescriptor descriptor) : base(warnings, descriptor) |
| | | 12 | | { |
| | 1 | 13 | | } |
| | | 14 | | public void ParseProperty(JProperty property) |
| | | 15 | | { |
| | 1 | 16 | | if (property.Value.Type == JTokenType.String) |
| | | 17 | | { |
| | 1 | 18 | | var rowTitlesValidator = new RowTitlesValidator(); |
| | 1 | 19 | | rowTitlesValidator.Validate(Descriptor); |
| | 1 | 20 | | Descriptor.rowTitles = new ColumnReferenceProperty(new List<string>() { property.Value.ToString() }); |
| | | 21 | | } |
| | 1 | 22 | | else if (property.Value.Type == JTokenType.Array) |
| | | 23 | | { |
| | 1 | 24 | | List<string> rowTitles = new List<string>(); |
| | 1 | 25 | | foreach (var referencedColumnName in property.Value) |
| | | 26 | | { |
| | 1 | 27 | | if (referencedColumnName.Type != JTokenType.String) |
| | | 28 | | { |
| | 0 | 29 | | Warnings.Add(WarningFactory.GetColumnReferencePropertyWrongValueWarning(property.Value, property |
| | 0 | 30 | | return; |
| | | 31 | | } |
| | | 32 | | else |
| | 1 | 33 | | rowTitles.Add(referencedColumnName.ToString()); |
| | | 34 | | |
| | | 35 | | } |
| | 1 | 36 | | if (rowTitles.Count > 0) |
| | | 37 | | { |
| | 1 | 38 | | var rowTitlesValidator = new RowTitlesValidator(); |
| | 1 | 39 | | rowTitlesValidator.Validate(Descriptor); |
| | 1 | 40 | | Descriptor.rowTitles = new ColumnReferenceProperty(rowTitles); |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | else |
| | 0 | 44 | | Warnings.Add(WarningFactory.GetColumnReferencePropertyWrongValueWarning(property.Value, property.Nam |
| | | 45 | | } |
| | | 46 | | else |
| | 0 | 47 | | Warnings.Add(WarningFactory.GetColumnReferencePropertyWrongValueWarning(property.Value, property.Name, p |
| | 0 | 48 | | } |
| | | 49 | | } |
| | | 50 | | } |