本文整理汇总了C#中Rating.GetDescription方法的典型用法代码示例。如果您正苦于以下问题:C# Rating.GetDescription方法的具体用法?C# Rating.GetDescription怎么用?C# Rating.GetDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating.GetDescription方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GravatarImage
public static HtmlString GravatarImage(this HtmlHelper htmlHelper, string emailAddress, int size = 80, DefaultImage defaultImage = DefaultImage.MysteryMan, string defaultImageUrl = "", bool forceDefaultImage = false, Rating rating = 0, bool forceSecureRequest = false)
{
TagBuilder builder = new TagBuilder("img");
emailAddress = string.IsNullOrEmpty(emailAddress) ? string.Empty : emailAddress.Trim().ToLower();
builder.Attributes.Add("src", string.Format("{0}://{1}.gravatar.com/avatar/{2}?s={3}{4}{5}{6}", new object[] { (htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest) ? "https" : "http", (htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest) ? "secure" : "www", GetMd5Hash(emailAddress), size.ToString(), "&d=" + (!string.IsNullOrEmpty(defaultImageUrl) ? HttpUtility.UrlEncode(defaultImageUrl) : defaultImage.GetDescription()), forceDefaultImage ? "&f=y" : "", "&r=" + rating.GetDescription() }));
builder.Attributes.Add("class", "gravatar");
builder.Attributes.Add("alt", "Gravatar image");
return new HtmlString(builder.ToString(TagRenderMode.SelfClosing));
}
示例2: GravatarImage
/// <summary>
/// Returns a Globally Recognised Avatar as an <img /> - http://gravatar.com
/// </summary>
/// <param name="emailAddress">Email Address for the Gravatar</param>
/// <param name="defaultImage">Default image if user hasn't created a Gravatar</param>
/// <param name="size">Size in pixels (default: 80)</param>
/// <param name="defaultImageUrl">URL to a custom default image (e.g: 'Url.Content("~/images/no-grvatar.png")' )</param>
/// <param name="forceDefaultImage">Prefer the default image over the users own Gravatar</param>
/// <param name="rating">Gravatar content rating (note that Gravatars are self-rated)</param>
/// <param name="forceSecureRequest">Always do secure (https) requests</param>
public static IHtmlContent GravatarImage(
this IHtmlHelper htmlHelper,
string emailAddress,
int size = 80,
DefaultImage defaultImage = DefaultImage.Default,
string defaultImageUrl = "",
bool forceDefaultImage = false,
Rating rating = Rating.G,
bool forceSecureRequest = false)
{
var imgTag = new TagBuilder("img");
emailAddress = string.IsNullOrEmpty(emailAddress) ? string.Empty : emailAddress.Trim().ToLower();
imgTag.Attributes.Add("src",
string.Format("{0}://{1}.gravatar.com/avatar/{2}?s={3}{4}{5}{6}",
htmlHelper.ViewContext.HttpContext.Request.IsHttps || forceSecureRequest ? "https" : "http",
htmlHelper.ViewContext.HttpContext.Request.IsHttps || forceSecureRequest ? "secure" : "www",
GetMd5Hash(emailAddress),
size.ToString(),
"&d=" + (!string.IsNullOrEmpty(defaultImageUrl) ? htmlHelper.UrlEncoder.Encode(defaultImageUrl) : defaultImage.GetDescription()),
forceDefaultImage ? "&f=y" : "",
"&r=" + rating.GetDescription()
)
);
imgTag.Attributes.Add("class", "gravatar");
imgTag.Attributes.Add("alt", "Gravatar image");
imgTag.TagRenderMode = TagRenderMode.SelfClosing;
return imgTag;
}
示例3: GravatarImageProfile
public static HtmlString GravatarImageProfile(
this HtmlHelper htmlHelper,
string emailAddress,
int size = 80,
DefaultImage defaultImage = DefaultImage.Default,
string defaultImageUrl = "",
bool forceDefaultImage = false,
Rating rating = Rating.G,
bool forceSecureRequest = false)
{
var imgTag = new TagBuilder("img");
emailAddress = string.IsNullOrEmpty(emailAddress) ? string.Empty : emailAddress.Trim().ToLower();
imgTag.Attributes.Add("src",
string.Format("{0}://{1}.gravatar.com/avatar/{2}?s={3}{4}{5}{6}",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "https" : "http",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "secure" : "www",
GetMd5Hash(emailAddress),
size.ToString(),
"&d=" + (!string.IsNullOrEmpty(defaultImageUrl) ? HttpUtility.UrlEncode(defaultImageUrl) : defaultImage.GetDescription()),
forceDefaultImage ? "&f=y" : "",
"&r=" + rating.GetDescription()
)
);
imgTag.Attributes.Add("class", "profile-user-img img-responsive img-circle");
imgTag.Attributes.Add("alt", "User profile picture");
return new HtmlString(imgTag.ToString(TagRenderMode.SelfClosing));
}
示例4: GravatarImage
/// <summary>
/// Returns a Globally Recognised Avatar as an <img /> - http://gravatar.com
/// </summary>
private static HtmlString GravatarImage(this HtmlHelper htmlHelper, string emailAddress, int size, DefaultImage defaultImage, string defaultImageUrl, bool forceDefaultImage, Rating rating, bool forceSecureRequest) {
var imgTag = new TagBuilder("img");
emailAddress = String.IsNullOrEmpty(emailAddress) ? String.Empty : emailAddress.Trim().ToLower();
imgTag.Attributes.Add("src",
string.Format("{0}://{1}.gravatar.com/avatar/{2}?s={3}{4}{5}{6}",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "https" : "http",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "secure" : "www",
GetMd5Hash(emailAddress),
size.ToString(),
"&d=" + (!string.IsNullOrEmpty(defaultImageUrl) ? HttpUtility.UrlEncode(defaultImageUrl) : defaultImage.GetDescription()),
forceDefaultImage ? "&f=y" : "",
"&r=" + rating.GetDescription()
)
);
imgTag.Attributes.Add("class", "gravatar");
imgTag.Attributes.Add("alt", "Gravatar image");
return new HtmlString(imgTag.ToString(TagRenderMode.SelfClosing));
}
示例5: GravatarImage
/// <summary>
/// Returns a Globally Recognised Avatar as an <img /> - http://gravatar.com
/// </summary>
/// <param name="emailAddress">Email Address for the Gravatar</param>
/// <param name="defaultImage">Default image if user hasn't created a Gravatar</param>
/// <param name="size">Size in pixels (default: 80)</param>
/// <param name="defaultImageUrl">URL to a custom default image (e.g: 'Url.Content("~/images/no-grvatar.png")' )</param>
/// <param name="forceDefaultImage">Prefer the default image over the users own Gravatar</param>
/// <param name="rating">Gravatar content rating (note that Gravatars are self-rated)</param>
/// <param name="forceSecureRequest">Always do secure (https) requests</param>
public static HtmlString GravatarImage(
this HtmlHelper htmlHelper,
string emailAddress,
IDictionary<string, string> htmlAttributes = null,
int size = 80,
DefaultImage defaultImage = DefaultImage.Default,
string defaultImageUrl = "",
bool forceDefaultImage = false,
Rating rating = Rating.G,
bool forceSecureRequest = false)
{
var imgTag = new TagBuilder("img");
emailAddress = string.IsNullOrEmpty(emailAddress) ? string.Empty : emailAddress.Trim().ToLower();
if (HttpContext.Current.Request.Url.Host.ToLower().Equals("localhost"))
{
imgTag.Attributes.Add("src", (htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "https://" : "http://") + defaultImageUrl);
imgTag.Attributes.Add("width", size.ToString());
imgTag.Attributes.Add("height", size.ToString());
}
else
{
imgTag.Attributes.Add("src",
string.Format("{0}://{1}.gravatar.com/avatar/{2}?s={3}{4}{5}{6}",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "https" : "http",
htmlHelper.ViewContext.HttpContext.Request.IsSecureConnection || forceSecureRequest ? "secure" : "www",
GetMd5Hash(emailAddress),
size.ToString(),
"&d=" + (!string.IsNullOrEmpty(defaultImageUrl) ? HttpUtility.UrlEncode(defaultImageUrl) : defaultImage.GetDescription()),
forceDefaultImage ? "&f=y" : "",
"&r=" + rating.GetDescription()
)
);
}
imgTag.Attributes.Add("alt", "Gravatar image");
if (htmlAttributes != null)
{
foreach (var attr in htmlAttributes)
{
if (imgTag.Attributes.Keys.Contains(attr.Key))
imgTag.Attributes[attr.Key] = attr.Value;
else
imgTag.Attributes.Add(attr.Key, attr.Value);
}
}
return new HtmlString(imgTag.ToString(TagRenderMode.SelfClosing));
}