本文整理汇总了C#中Rating.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Rating.ToString方法的具体用法?C# Rating.ToString怎么用?C# Rating.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetURL
public static string GetURL (string email, int size, Rating rating = Rating.PG)
{
var hash = MD5Hash (email.ToLower ());
if (size < 1 | size > 600) {
throw new ArgumentOutOfRangeException("size", "The image size should be between 20 and 80");
}
return _url + hash + "&s=" + size.ToString () + "&r=" + rating.ToString ().ToLower ();
}
示例2: GetURL
public static string GetURL(string email, int size, Rating rating = Rating.PG)
{
var hash = MD5Hash(email.ToLower());
if (size < 1 | size > 600)
{
throw new ArgumentOutOfRangeException("size", "The image size should be between 20 and 80");
}
return string.Format("{0}{1}&s={2}&r={3}", _url, hash, size, rating.ToString().ToLower());
}
示例3: GetImageSource
public static string GetImageSource(string email, string defaultImage, int size=80, Rating maxRating=Rating.X)
{
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(email.Trim()))
return defaultImage;
var imageUrl = "http://www.gravatar.com/avatar.php?";
var encoder = new UTF8Encoding();
var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
var hashedBytes = md5.ComputeHash(encoder.GetBytes(email.ToLower()));
var sb = new StringBuilder(hashedBytes.Length*2);
for (var i = 0; i < hashedBytes.Length; i++)
sb.Append(hashedBytes[i].ToString("X2"));
imageUrl += "gravatar_id=" + sb.ToString().ToLower();
imageUrl += "&rating=" + maxRating.ToString();
imageUrl += "&size=" + size.ToString();
if (!string.IsNullOrEmpty(defaultImage))
imageUrl += "&default=" + System.Web.HttpUtility.UrlEncode(defaultImage);
return imageUrl;
}
示例4: BuildGravatarUrl
/// <summary>
/// Builds a <see cref="System.Uri"/> corresponding to a given email address.
/// </summary>
/// <param name="email">The email address for which to build the <see cref="System.Uri"/>.</param>
/// <param name="size">The size of the image to request. The default is 32.</param>
/// <param name="useHttps">Indicates whether or not the request should be performed over Secure HTTP.</param>
/// <param name="rating">The mazimum rating of the returned image.</param>
/// <param name="fallBack">The Gravatar service that will be used for fall-back.</param>
/// <returns>The constructed <see cref="System.Uri"/>.</returns>
private static Uri BuildGravatarUrl(string email, int size, bool useHttps, Rating rating, FallBackService fallBack)
{
var builder = new UriBuilder("http://www.gravatar.com/avatar/");
if (useHttps)
{
builder.Scheme = "https";
}
builder.Path += HashEmail(email);
string d;
if (!fallBackStrings.TryGetValue(fallBack, out d))
{
d = "404";
}
var query = string.Format("s={0}&r={1}&d={2}",
size.ToString(),
rating.ToString().ToLowerInvariant(),
d);
builder.Query = query;
return builder.Uri;
}