コード例 #1
0
ファイル: JiraApi.cs プロジェクト: Miranous/Dapplo.Jira
        /// <summary>
        ///     Retrieve the Avatar for the supplied avatarUrls object
        /// </summary>
        /// <typeparam name="TResponse">the type to return the result into. e.g. Bitmap,BitmapSource or MemoryStream</typeparam>
        /// <param name="avatarUrls">AvatarUrls object from User or Myself method, or a project from the projects</param>
        /// <param name="avatarSize">Use one of the AvatarSizes to specify the size you want to have</param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>Bitmap,BitmapSource or MemoryStream (etc) depending on TResponse</returns>
        public async Task <TResponse> GetAvatarAsync <TResponse>(AvatarUrls avatarUrls, AvatarSizes avatarSize = AvatarSizes.ExtraLarge,
                                                                 CancellationToken cancellationToken           = default(CancellationToken))
            where TResponse : class
        {
            var avatarUri = avatarUrls.GetUri(avatarSize);

            _behaviour.MakeCurrent();

            return(await GetUriContentAsync <TResponse>(avatarUri, cancellationToken).ConfigureAwait(false));
        }
コード例 #2
0
        /// <summary>
        ///     Retrieve the Avatar for the supplied avatarUrls object
        /// </summary>
        /// <typeparam name="TResponse">the type to return the result into. e.g. Bitmap,BitmapSource or MemoryStream</typeparam>
        /// <param name="jiraClient">IServerDomain to bind the extension method to</param>
        /// <param name="avatarUrls">AvatarUrls object from User or Myself method, or a project from the projects</param>
        /// <param name="avatarSize">Use one of the AvatarSizes to specify the size you want to have</param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>Bitmap,BitmapSource or MemoryStream (etc) depending on TResponse</returns>
        public static async Task <TResponse> GetAvatarAsync <TResponse>(this IServerDomain jiraClient, AvatarUrls avatarUrls, AvatarSizes avatarSize = AvatarSizes.ExtraLarge,
                                                                        CancellationToken cancellationToken = default)
            where TResponse : class
        {
            var avatarUri = avatarUrls.GetUri(avatarSize);

            jiraClient.Behaviour.MakeCurrent();

            return(await jiraClient.GetUriContentAsync <TResponse>(avatarUri, cancellationToken).ConfigureAwait(false));
        }