private void ExecuteGravatarMethodAsync(GravatarServiceRequest request, GravatarCallBack callback, object state)
        {
            var webRequest = (HttpWebRequest)WebRequest.Create(String.Format(GravatarApiUrl, HashEmailAddress(Email)));

            webRequest.Method      = "POST";
            webRequest.ContentType = "text/xml";

            webRequest.BeginGetRequestStream(OnGetRequestStream, new GravatarRequestState {
                WebRequest      = webRequest,
                GravatarRequest = request,
                UserState       = state,
                CallBack        = callback
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Use a userimage as a gravatar for one of more addresses on this account - called asynchronously
        /// </summary>
        /// <param name="userImage">The userimage you wish to use</param>
        /// <param name="addresses">A list of the email addresses you wish to use this userimage for</param>
        /// <param name="callback">The callback activated when action finishes</param>
        /// <param name="state">Custom parameter to callback</param>
        /// <returns>If the method call is successful, the result will be returned using the MultipleOperationResponse property
        /// of the <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
        /// The response is returned to the callback method</returns>
        public void UseUserImageAsync(string userImage, string[] addresses, GravatarCallBack callback, object state)
        {
            var request = GetUseUserImagesMethodRequest(userImage, addresses);

            ExecuteGravatarMethodAsync(request, callback, state);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Remove a userimage from the account and any email addresses with which it is associated - called asynchronously
        /// </summary>
        /// <param name="userImage">The user image you wish to remove from the account</param>
        /// <param name="callback">The callback activated when action finishes</param>
        /// <param name="state">Custom parameter to callback</param>
        /// <returns>If the method call is successful, the result will be returned using the BooleanResponse property of the
        /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
        /// The response is returned to the callback method</returns>
        public void DeleteUserImageAsync(string userImage, GravatarCallBack callback, object state)
        {
            var request = GetDeleteImageMethodRequest(userImage);

            ExecuteGravatarMethodAsync(request, callback, state);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Save binary image data as a userimage for this account - called asynchronously
        /// </summary>
        /// <param name="data">The image data in bytes</param>
        /// <param name="rating">The rating of the image (g, pg, r, x)</param>
        /// <param name="callback">The callback activated when action finishes</param>
        /// <param name="state">Custom parameter to callback</param>
        /// <returns>If the method call is successful, the result will be returned using the SaveResponse property of the
        /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
        /// The response is returned to the callback method</returns>
        public void SaveDataAsync(byte[] data, GravatarImageRating rating, GravatarCallBack callback, object state)
        {
            var request = GetSaveDataMethodRequest(data, rating);

            ExecuteGravatarMethodAsync(request, callback, state);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Read an image via its URL and save that as a userimage for this account - called asynchronously
        /// </summary>
        /// <param name="url">a full url to an image</param>
        /// <param name="rating">The rating of the image (g, pg, r, x)</param>
        /// <param name="callback">The callback activated when action finishes</param>
        /// <param name="state">Custom parameter to callback</param>
        /// <returns>If the method call is successful, the result will be returned using the SaveResponse property of the
        /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
        /// The response is returned to the callback method</returns>
        public void SaveUrlAsync(string url, GravatarImageRating rating, GravatarCallBack callback, object state)
        {
            var request = GetSaveUrlMethodRequest(url, rating);

            ExecuteGravatarMethodAsync(request, callback, state);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Check whether a hash has a gravatar - called asynchronously
        /// </summary>
        /// <param name="addresses">an array of hashes to check</param>
        /// <param name="callback">The callback activated when action finishes</param>
        /// <param name="state">Custom parameter to callback</param>
        /// <returns>If the method call is successful, the result will be returned using the MultipleOperationResponse property
        /// of the <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
        /// The response is returned to the callback method</returns>
        public void ExistsAsync(string[] addresses, GravatarCallBack callback, object state)
        {
            var request = GetExistsMethodRequest(addresses);

            ExecuteGravatarMethodAsync(request, callback, state);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Return an array of userimages for this account - called asynchronously
        /// </summary>
        /// <param name="callback">The callback activated when action finishes</param>
        /// <param name="state">Custom parameter to callback</param>
        /// <returns>If the method call is successful, the result will be returned using the ImagesResponse property of the
        /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
        /// The response is returned to the callback method</returns>
        public void UserImagesAsync(GravatarCallBack callback, object state)
        {
            var request = GetUserImagesMethodRequest();

            ExecuteGravatarMethodAsync(request, callback, state);
        }
        private void ExecuteGravatarMethodAsync(GravatarServiceRequest request, GravatarCallBack callback, object state)
        {
            var webRequest = (HttpWebRequest) WebRequest.Create(String.Format(GravatarApiUrl, HashEmailAddress(Email)));

            webRequest.Method = "POST";
            webRequest.ContentType = "text/xml";

            webRequest.BeginGetRequestStream(OnGetRequestStream,  new GravatarRequestState {
                WebRequest = webRequest,
                GravatarRequest = request,
                UserState = state,
                CallBack = callback
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// A test function - called asynchronously
        /// </summary>
        /// <param name="callback">The callback activated when action finishes</param>
        /// <param name="state">Custom parameter to callback</param>
        /// <returns>If the method call is successful, the result will be returned using the IntegerResponse property of the
        /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method.
        /// The response is returned to the callback method
        /// </returns>
        public void TestAsync(GravatarCallBack callback, object state)
        {
            var request = GetTestMethodRequest();

            ExecuteGravatarMethodAsync(request, callback, state);
        }
 /// <summary>
 /// Return an array of userimages for this account - called asynchronously
 /// </summary>
 /// <param name="callback">The callback activated when action finishes</param>
 /// <param name="state">Custom parameter to callback</param>
 /// <returns>If the method call is successful, the result will be returned using the ImagesResponse property of the
 /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
 /// The response is returned to the callback method</returns>
 public void UserImagesAsync(GravatarCallBack callback, object state)
 {
     var request = GetUserImagesMethodRequest();
     ExecuteGravatarMethodAsync(request, callback, state);
 }
 /// <summary>
 /// Use a userimage as a gravatar for one of more addresses on this account - called asynchronously 
 /// </summary>
 /// <param name="userImage">The userimage you wish to use</param>
 /// <param name="addresses">A list of the email addresses you wish to use this userimage for</param>
 /// <param name="callback">The callback activated when action finishes</param>
 /// <param name="state">Custom parameter to callback</param>
 /// <returns>If the method call is successful, the result will be returned using the MultipleOperationResponse property
 /// of the <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
 /// The response is returned to the callback method</returns>
 public void UseUserImageAsync(string userImage, string[] addresses, GravatarCallBack callback, object state)
 {
     var request = GetUseUserImagesMethodRequest(userImage, addresses);
     ExecuteGravatarMethodAsync(request, callback, state);
 }
 /// <summary>
 /// A test function - called asynchronously
 /// </summary>
 /// <param name="callback">The callback activated when action finishes</param>
 /// <param name="state">Custom parameter to callback</param>
 /// <returns>If the method call is successful, the result will be returned using the IntegerResponse property of the 		
 /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method.
 /// The response is returned to the callback method
 /// </returns>
 public void TestAsync(GravatarCallBack callback, object state)
 {
     var request = GetTestMethodRequest();
     ExecuteGravatarMethodAsync(request, callback, state);
 }
 /// <summary>
 /// Read an image via its URL and save that as a userimage for this account - called asynchronously 
 /// </summary>
 /// <param name="url">a full url to an image</param>
 /// <param name="rating">The rating of the image (g, pg, r, x)</param>
 /// <param name="callback">The callback activated when action finishes</param>
 /// <param name="state">Custom parameter to callback</param>
 /// <returns>If the method call is successful, the result will be returned using the SaveResponse property of the
 /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
 /// The response is returned to the callback method</returns>
 public void SaveUrlAsync(string url, GravatarImageRating rating, GravatarCallBack callback, object state)
 {
     var request = GetSaveUrlMethodRequest(url, rating);
     ExecuteGravatarMethodAsync(request, callback, state);
 }
 /// <summary>
 /// Save binary image data as a userimage for this account - called asynchronously
 /// </summary>
 /// <param name="data">The image data in bytes</param>
 /// <param name="rating">The rating of the image (g, pg, r, x)</param>
 /// <param name="callback">The callback activated when action finishes</param>
 /// <param name="state">Custom parameter to callback</param>
 /// <returns>If the method call is successful, the result will be returned using the SaveResponse property of the
 /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
 /// The response is returned to the callback method</returns>
 public void SaveDataAsync(byte[] data, GravatarImageRating rating, GravatarCallBack callback, object state)
 {
     var request = GetSaveDataMethodRequest(data, rating);
     ExecuteGravatarMethodAsync(request, callback, state);
 }
 /// <summary>
 /// Check whether a hash has a gravatar - called asynchronously
 /// </summary>
 /// <param name="addresses">an array of hashes to check</param>
 /// <param name="callback">The callback activated when action finishes</param>
 /// <param name="state">Custom parameter to callback</param>
 /// <returns>If the method call is successful, the result will be returned using the MultipleOperationResponse property
 /// of the <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
 /// The response is returned to the callback method</returns>
 public void ExistsAsync(string[] addresses, GravatarCallBack callback, object state)
 {
     var request = GetExistsMethodRequest(addresses);
     ExecuteGravatarMethodAsync(request, callback, state);
 }
 /// <summary>
 /// Remove a userimage from the account and any email addresses with which it is associated - called asynchronously 
 /// </summary>
 /// <param name="userImage">The user image you wish to remove from the account</param>
 /// <param name="callback">The callback activated when action finishes</param>
 /// <param name="state">Custom parameter to callback</param>
 /// <returns>If the method call is successful, the result will be returned using the BooleanResponse property of the
 /// <see cref="Gravatar.NET.GravatarServiceResponse"/> instance returned by this method
 /// The response is returned to the callback method</returns>
 public void DeleteUserImageAsync(string userImage, GravatarCallBack callback, object state)
 {
     var request = GetDeleteImageMethodRequest(userImage);
     ExecuteGravatarMethodAsync(request, callback, state);
 }