/// <summary> /// Gets the single CLR resource identifier for the given CLR resource type. /// </summary> /// <remarks> /// The CLR based resource identifier can come from either a json:api resource object or /// a resource identifier. /// </remarks> /// <typeparam name="TResource">Type of CLR resource to find.</typeparam> /// <typeparam name="TResourceId">Type of CLR resource identifier.</typeparam> /// <returns>Returns the single CLR resource identifier if it exists, null otherwise.</returns> /// <exception cref="DocumentReadException">Is thrown if there are /// multiple CLR resource identifiers for the given CLR resource type.</exception> public static TResourceId GetResourceId <TResource, TResourceId>(this IDocumentReader documentReader) where TResource : class, IResource { Contract.Requires(documentReader != null); var clrResourceType = typeof(TResource); var clrResourceId = documentReader.GetResourceId <TResourceId>(clrResourceType); return(clrResourceId); }