| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | 3 | | using ValidateLib.Metadata.Descriptors; |
| | 4 | | using ValidateLib.Metadata.Properties; |
| | 5 | |
|
| | 6 | | namespace ValidateLib.Metadata.PropertyParsers.Reference |
| | 7 | | { |
| | 8 | | internal class ColumnReferencePropertyParser : PropertyParserBase<ReferenceDescriptor>, IPropertyParser<ReferenceDes |
| | 9 | | { |
| 1 | 10 | | public ColumnReferencePropertyParser(List<Warning> warnings, ReferenceDescriptor descriptor) : base(warnings, de |
| | 11 | | { |
| 1 | 12 | | } |
| | 13 | | public void ParseProperty(JProperty property) |
| | 14 | | { |
| 1 | 15 | | if (property.Value.Type == JTokenType.String) |
| 1 | 16 | | Descriptor.columnReference = new ColumnReferenceProperty(new List<string>() { property.Value.ToString() |
| 1 | 17 | | else if (property.Value.Type == JTokenType.Array) |
| | 18 | | { |
| 1 | 19 | | List<string> primaryKeys = new List<string>(); |
| 1 | 20 | | foreach (var referencedColumnName in property.Value) |
| | 21 | | { |
| 1 | 22 | | if (referencedColumnName.Type != JTokenType.String) |
| | 23 | | { |
| 0 | 24 | | Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.V |
| 0 | 25 | | return; |
| | 26 | | } |
| | 27 | | else |
| 1 | 28 | | primaryKeys.Add(referencedColumnName.ToString()); |
| | 29 | |
|
| | 30 | | } |
| 1 | 31 | | if (primaryKeys.Count > 0) |
| 1 | 32 | | Descriptor.columnReference = new ColumnReferenceProperty(primaryKeys); |
| | 33 | | else |
| 0 | 34 | | Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value |
| | 35 | | } |
| | 36 | | else |
| 0 | 37 | | Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value.Typ |
| 0 | 38 | | } |
| | 39 | | } |
| | 40 | | } |