示例#1
0
 private void VerifyHeading()
 {
     if (this.relation.Heading.Count != this.relation.Heading.Distinct().Count())
     {
         throw RelationException.FromRelation(this.relation, $"Duplicate attribute found.");
     }
 }
示例#2
0
 private void Validate()
 {
     for (int i = 0; i < this.headingMetadata.Length; i++)
     {
         if (this.headingMetadata[i] == null)
         {
             throw RelationException.FromRelation(this.relation, $"Metadata for attribute name '{this.relation.Heading[i]}' not found at index {i}.");
         }
     }
 }
示例#3
0
        private IEnumerable <IRelationMetadata> Path(IRelationMetadata metadata)
        {
            IRelationMetadata origin = metadata;

            while (!this.sourceMetadata.Equals(metadata) && metadata != null)
            {
                yield return(metadata);

                metadata = metadata.Parent;
            }

            if (metadata == null)
            {
                throw RelationException.FromRelation(this.relation, $"No relationship found between '{this.sourceMetadata.Identity.Name}' and '{origin.Identity.Name}'.");
            }

            yield return(metadata);
        }
示例#4
0
        public static NodeTree Parse(MetadataIdentity source, IRelationHeader header)
        {
            NodeTree tree = new NodeTree();

            IRelationMetadata sourceMetadata = GetMetadata(source);

            tree.Source = AddSourceNode(tree, sourceMetadata);

            for (int i = 0; i < header.Degree; i++)
            {
                AddNode(tree, header.Attributes[i], index: i);
            }

            if (tree.Unreachable.Any())
            {
                throw RelationException.Unreachable(source, header, tree.Unreachable);
            }

            return(tree);
        }