Ejemplo n.º 1
0
        private IJsonMetadata GetMetadata(IMetadataBuilderContext context, MetadataIdentity identity)
        {
            MetadataIdentity  parentIdentity = identity.Parent();
            IJsonMetadata     parent         = context.GetMetadata <IJsonMetadata>(parentIdentity.Name) ?? this.GetMetadata(context, parentIdentity);
            IRelationMetadata relation       = identity.GetMetadata <IRelationMetadata>();

            if (parent == null || relation == null)
            {
                return(null);
            }

            JsonMetadata metadata = new JsonMetadata(relation);

            if (this.HasJsonAttribute(relation) || relation.HasFlag(RelationMetadataFlags.Item))
            {
                metadata.MemberOf = metadata;
                metadata.IsRoot   = true;
                metadata.Path     = "$";
            }
            else
            {
                metadata.MemberOf = parent.MemberOf;
                metadata.IsRoot   = false;
                metadata.Path     = $"{parent.Path}.{this.GetPropertyNameFromContract(metadata)}";
            }

            context.AddMetadata <IJsonMetadata>(metadata);

            return(metadata);
        }
        private ITableMetadata GetMetadata(IMetadataBuilderContext context, IRelationMetadata relation)
        {
            ITableMetadata parent = context.GetMetadata <ITableMetadata>(relation.Parent.Identity.Name) ?? this.GetMetadata(context, relation.Parent);

            if (parent == null)
            {
                return(null);
            }
            else if (parent.Item != null && parent.Item.Identity.Equals(relation.Identity))
            {
                return(parent.Item);
            }

            return(parent.Properties.FirstOrDefault(m => m.Identity.Equals(relation.Identity)));
        }
Ejemplo n.º 3
0
        private IRelationMetadata GetMetadata(IMetadataBuilderContext context, MetadataIdentity identity)
        {
            MetadataIdentity  parentIdentity = identity.Parent();
            IRelationMetadata parent         = context.GetMetadata <IRelationMetadata>(parentIdentity.Name) ?? this.GetMetadata(context, parentIdentity);

            if (parent == null)
            {
                return(null);
            }
            else if (parent.Item != null && parent.Item.Identity.Equals(identity))
            {
                return(parent.Item);
            }

            return(parent.Properties.FirstOrDefault(m => m.Identity.Equals(identity)));
        }