コード例 #1
0
        /// <summary>
        /// Gets the single resource or resource identifier json:api meta object by resource identifier lookup.
        /// </summary>
        /// <typeparam name="TResource">Type of CLR resource.</typeparam>
        /// <typeparam name="TResourceId">Type of CLR resource identifier.</typeparam>
        /// <param name="clrResourceId">CLR resource identifier value to lookup the single json:api meta object with.</param>
        /// <returns>Returns the single json:api meta object if found, null otherwise.</returns>
        /// <exception cref="DocumentReadException">Is thrown if there are
        /// multiple CLR resources or resource identifiers with the same resource identifier for the given CLR resource type.</exception>
        public static Meta GetResourceMeta <TResource, TResourceId>(this IDocumentReader documentReader, TResourceId clrResourceId)
            where TResource : class, IResource
        {
            Contract.Requires(documentReader != null);

            var clrResourceType = typeof(TResource);
            var apiResourceMeta = documentReader.GetResourceMeta(clrResourceType, clrResourceId);

            return(apiResourceMeta);
        }