/// <summary> /// Gets the single CLR resource by resource identifier lookup. /// </summary> /// <typeparam name="TResource">Type of CLR resource to find.</typeparam> /// <typeparam name="TResourceId">Type of CLR resource identifier.</typeparam> /// <param name="clrResourceId">CLR resource identifier value to lookup the single CLR resource with.</param> /// <returns>Returns the single CLR resource if found, null otherwise.</returns> /// <exception cref="DocumentReadException">Is thrown if there are /// multiple CLR resources with the same resource identifier for the given CLR resource type.</exception> public static TResource GetResource <TResource, TResourceId>(this IDocumentReader documentReader, TResourceId clrResourceId) where TResource : class, IResource { Contract.Requires(documentReader != null); var clrResourceType = typeof(TResource); var clrResource = (TResource)documentReader.GetResource(clrResourceType, clrResourceId); return(clrResource); }