Beispiel #1
0
		/// <summary>
		/// Helper method to get the Uri for a certain avatar size
		/// </summary>
		/// <param name="avatarSize"></param>
		/// <returns>Uri</returns>
		/// <exception cref="ArgumentException">when an unknown avatar size is requested</exception>
		public Uri GetUri(AvatarSizes avatarSize)
		{
			switch (avatarSize)
			{
				case AvatarSizes.Small:
					return Small;
				case AvatarSizes.Medium:
					return Medium;
				case AvatarSizes.Large:
					return Large;
				case AvatarSizes.ExtraLarge:
					return ExtraLarge;
				default:
					throw new ArgumentException($"Unknown avatar size: {avatarSize}", nameof(avatarSize));
			}
		}
Beispiel #2
0
        /// <summary>
        ///     Helper method to get the Uri for a certain avatar size
        /// </summary>
        /// <param name="avatarSize"></param>
        /// <returns>Uri</returns>
        /// <exception cref="ArgumentException">when an unknown avatar size is requested</exception>
        public Uri GetUri(AvatarSizes avatarSize)
        {
            switch (avatarSize)
            {
            case AvatarSizes.Small:
                return(Small);

            case AvatarSizes.Medium:
                return(Medium);

            case AvatarSizes.Large:
                return(Large);

            case AvatarSizes.ExtraLarge:
                return(ExtraLarge);

            default:
                throw new ArgumentException($"Unknown avatar size: {avatarSize}", nameof(avatarSize));
            }
        }
Beispiel #3
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));
        }
Beispiel #4
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="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));
        }