Ejemplo n.º 1
0
        /// <summary>
        /// Specify a to-many relationship of this resource.
        /// </summary>
        /// <typeparam name="T">The api resource type of the relationship.</typeparam>
        /// <param name="name">The name of the relationship.</param>
        /// <param name="path">The url pathspec of this relationship (default is the name).</param>
        /// <param name="withLinks">The defined <see cref="LinkType" /> to be generated for this relationship.</param>
        /// <returns>
        /// The <see cref="ResourceRelationship" />.
        /// </returns>
        protected ResourceRelationship HasMany <T>(string name, string path, LinkType withLinks)
            where T : ApiResource, new()
        {
            VerifyPropertyName(name);

            var resource = GetUniqueResource <T>();
            var result   = new ResourceRelationship <T>(name, path, RelationshipKind.HasMany, resource, withLinks);

            _relationships.Add(result);

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Specify a to-one relationship of this resource.
        /// </summary>
        /// <param name="name">The name of the relationship.</param>
        /// <param name="path">The url pathspec of this relationship (default
        /// is the name)</param>
        /// <typeparam name="T">The api resource type of the relationship.</typeparam>
        /// <returns>The <see cref="ResourceRelationship"/>.</returns>
        protected ResourceRelationship BelongsTo <T>(string name, string path)
            where T : ApiResource, new()
        {
            VerifyPropertyName(name);

            var resource = GetUniqueResource <T>();
            var result   = new ResourceRelationship <T>(name, path, RelationshipKind.BelongsTo, resource);

            _relationships.Add(result);

            return(result);
        }
Ejemplo n.º 3
0
 public string BuildRelationshipPath(ApiResource resource, string id, ResourceRelationship relationship,
     string relatedResourceId)
 {
     return string.Empty;
 }