| | 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.ForeignKey |
| | 7 | | { |
| | 8 | | internal class ColumnReferencePropertyParser : PropertyParserBase<ForeignKeyDescriptor>, IPropertyParser<ForeignKeyD |
| | 9 | | { |
| 1 | 10 | | public ColumnReferencePropertyParser(List<Warning> warnings, ForeignKeyDescriptor descriptor) : base(warnings, d |
| | 11 | | { |
| 1 | 12 | | } |
| | 13 | |
|
| | 14 | | public void ParseProperty(JProperty property) |
| | 15 | | { |
| 1 | 16 | | if (property.Value.Type == JTokenType.String) |
| 1 | 17 | | Descriptor.columnReference = new ColumnReferenceProperty(new List<string>() { property.Value.ToString() |
| 1 | 18 | | else if (property.Value.Type == JTokenType.Array) |
| | 19 | | { |
| 1 | 20 | | List<string> referencingColumns = new List<string>(); |
| 1 | 21 | | foreach (var referencedColumnName in property.Value) |
| | 22 | | { |
| 1 | 23 | | if (referencedColumnName.Type != JTokenType.String) |
| | 24 | | { |
| 0 | 25 | | Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.V |
| 0 | 26 | | return; |
| | 27 | | } |
| | 28 | | else |
| 1 | 29 | | referencingColumns.Add(referencedColumnName.ToString()); |
| | 30 | |
|
| | 31 | | } |
| 1 | 32 | | if (referencingColumns.Count > 0) |
| 1 | 33 | | Descriptor.columnReference = new ColumnReferenceProperty(referencingColumns); |
| | 34 | | else |
| 0 | 35 | | Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value |
| | 36 | | } |
| | 37 | | else |
| 0 | 38 | | Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value.Typ |
| 0 | 39 | | } |
| | 40 | | } |
| | 41 | | } |