|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq.Expressions; |
| 4 | +using JsonApiDotNetCore.Models; |
| 5 | + |
| 6 | +namespace JsonApiDotNetCore.Internal.Contracts |
| 7 | +{ |
| 8 | + /// <summary> |
| 9 | + /// Responsible for retrieving the exposed resource fields (attributes and |
| 10 | + /// relationships) of registered resources in the resource graph. |
| 11 | + /// </summary> |
| 12 | + public interface IResourceGraphExplorer : IContextEntityProvider |
| 13 | + { |
| 14 | + /// <summary> |
| 15 | + /// Gets all fields (attributes and relationships) for <typeparamref name="TResource"/> |
| 16 | + /// that are targeted by the selector. If no selector is provided, all |
| 17 | + /// exposed fields are returned. |
| 18 | + /// </summary> |
| 19 | + /// <typeparam name="TResource">The resource for which to retrieve fields</typeparam> |
| 20 | + /// <param name="selector">Should be of the form: (TResource e) => new { e.Field1, e.Field2 }</param> |
| 21 | + List<IResourceField> GetFields<TResource>(Expression<Func<TResource, dynamic>> selector = null) where TResource : IIdentifiable; |
| 22 | + /// <summary> |
| 23 | + /// Gets all attributes for <typeparamref name="TResource"/> |
| 24 | + /// that are targeted by the selector. If no selector is provided, all |
| 25 | + /// exposed fields are returned. |
| 26 | + /// </summary> |
| 27 | + /// <typeparam name="TResource">The resource for which to retrieve attributes</typeparam> |
| 28 | + /// <param name="selector">Should be of the form: (TResource e) => new { e.Attribute1, e.Arttribute2 }</param> |
| 29 | + List<AttrAttribute> GetAttributes<TResource>(Expression<Func<TResource, dynamic>> selector = null) where TResource : IIdentifiable; |
| 30 | + /// <summary> |
| 31 | + /// Gets all relationships for <typeparamref name="TResource"/> |
| 32 | + /// that are targeted by the selector. If no selector is provided, all |
| 33 | + /// exposed fields are returned. |
| 34 | + /// </summary> |
| 35 | + /// <typeparam name="TResource">The resource for which to retrieve relationships</typeparam> |
| 36 | + /// <param name="selector">Should be of the form: (TResource e) => new { e.Relationship1, e.Relationship2 }</param> |
| 37 | + List<RelationshipAttribute> GetRelationships<TResource>(Expression<Func<TResource, dynamic>> selector = null) where TResource : IIdentifiable; |
| 38 | + /// <summary> |
| 39 | + /// Gets all exposed fields (attributes and relationships) for type <paramref name="type"/> |
| 40 | + /// </summary> |
| 41 | + /// <param name="type">The resource type. Must extend IIdentifiable.</param> |
| 42 | + List<IResourceField> GetFields(Type type); |
| 43 | + /// <summary> |
| 44 | + /// Gets all exposed attributes for type <paramref name="type"/> |
| 45 | + /// </summary> |
| 46 | + /// <param name="type">The resource type. Must extend IIdentifiable.</param> |
| 47 | + List<AttrAttribute> GetAttributes(Type type); |
| 48 | + /// <summary> |
| 49 | + /// Gets all exposed relationships for type <paramref name="type"/> |
| 50 | + /// </summary> |
| 51 | + /// <param name="type">The resource type. Must extend IIdentifiable.</param> |
| 52 | + List<RelationshipAttribute> GetRelationships(Type type); |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// Traverses the resource graph for the inverse relationship of the provided |
| 56 | + /// <paramref name="relationship"/>; |
| 57 | + /// </summary> |
| 58 | + /// <param name="relationship"></param> |
| 59 | + RelationshipAttribute GetInverse(RelationshipAttribute relationship); |
| 60 | + } |
| 61 | +} |
0 commit comments