/// <summary> /// 打开包含给定帖子的给定索引处的图片的数据流。 /// </summary> /// <param name="dataFacade"></param> /// <param name="postId">帖子 ID</param> /// <param name="imageIndex">图像索引</param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dataFacade"/>为null /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="imageIndex"/>小于0 或 大于等于9 /// </exception> public static async Task <Stream> OpenPostImage(this IDataFacade dataFacade, int postId, int imageIndex) { if (dataFacade == null) { throw new ArgumentNullException(nameof(dataFacade)); } if (imageIndex < 0 || imageIndex >= 9) { throw new ArgumentOutOfRangeException(nameof(imageIndex)); } var(indexEntity, contentEntity) = await FindPost(dataFacade, postId); if (imageIndex >= contentEntity.ImageIds.Length) { return(null); } var imageId = contentEntity.ImageIds[imageIndex]; if (imageId == null) { return(null); } return(await dataFacade.OpenImage(imageId.Value)); }