|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Diagnostics.Contracts; |
| 4 | + |
| 5 | +namespace ReClassNET.DataExchange |
| 6 | +{ |
| 7 | + [Serializable] |
| 8 | + public class SchemaNode |
| 9 | + { |
| 10 | + public SchemaType Type { get; } |
| 11 | + public string Name { get; set; } |
| 12 | + public string Comment { get; set; } |
| 13 | + public int Count { get; set; } = -1; |
| 14 | + |
| 15 | + public SchemaNode(SchemaType type) |
| 16 | + { |
| 17 | + Type = type; |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + [Serializable] |
| 22 | + public class SchemaReferenceNode : SchemaNode |
| 23 | + { |
| 24 | + public SchemaClassNode InnerNode { get; } |
| 25 | + |
| 26 | + public SchemaReferenceNode(SchemaType type, SchemaClassNode inner) |
| 27 | + : base(type) |
| 28 | + { |
| 29 | + Contract.Requires(inner != null); |
| 30 | + |
| 31 | + InnerNode = inner; |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + [Serializable] |
| 36 | + public class SchemaVTableNode : SchemaNode |
| 37 | + { |
| 38 | + public List<SchemaNode> Nodes { get; } = new List<SchemaNode>(); |
| 39 | + |
| 40 | + public SchemaVTableNode() |
| 41 | + : base(SchemaType.VTable) |
| 42 | + { |
| 43 | + |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + [Serializable] |
| 48 | + public class SchemaClassNode : SchemaNode |
| 49 | + { |
| 50 | + public string AddressFormula { get; set; } |
| 51 | + public List<SchemaNode> Nodes { get; } = new List<SchemaNode>(); |
| 52 | + |
| 53 | + public SchemaClassNode() |
| 54 | + : base(SchemaType.Class) |
| 55 | + { |
| 56 | + |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + public class SchemaClassNodeEqualityComparer : IEqualityComparer<SchemaClassNode> |
| 61 | + { |
| 62 | + public bool Equals(SchemaClassNode c1, SchemaClassNode c2) |
| 63 | + { |
| 64 | + if (c2 == null && c1 == null) |
| 65 | + { |
| 66 | + return true; |
| 67 | + } |
| 68 | + if (c1 == null | c2 == null) |
| 69 | + { |
| 70 | + return false; |
| 71 | + } |
| 72 | + if (c1.Name == c2.Name) |
| 73 | + { |
| 74 | + return true; |
| 75 | + } |
| 76 | + |
| 77 | + return false; |
| 78 | + } |
| 79 | + |
| 80 | + public int GetHashCode(SchemaClassNode c) |
| 81 | + { |
| 82 | + return c.Name.GetHashCode(); |
| 83 | + } |
| 84 | + } |
| 85 | +} |
0 commit comments