示例#1
0
 /// <exclude />
 private static string Substitute(string url, string subject, string status, ShieldColor? color, ShieldImage? image, ShieldStyle? style)
 {
     var newUrl = url
         .Replace("{subject}", subject as string)
         .Replace("{status}", status as string)
         .Replace("{color}", color.ToStr())
         .Replace("{image}", image.ToStr());
     if (style != ShieldStyle.Flat)
         newUrl += string.Format("?style={0}", style.ToStr());
     return newUrl;
 }
示例#2
0
        /// <exclude />
        public static FluentTagBuilder GenerateShieldMarkup(string subject, ShieldType? type = null, string status = null, ShieldColor color = ShieldColor.Green, ShieldStyle style = ShieldStyle.Flat, ShieldImage image = ShieldImage.Png)
        {
            string url;
            subject = subject.Split(' ')[0];
            if (type == null)
                url = Substitute("https://img.shields.io/badge/{subject}-{status}-{color}.{image}", subject.Replace("-", ""), status, color, image, style);
            else
                url = Substitute(GithubForkmeMask[(ShieldType)type], subject, status, color, image, style);

            return new FluentTagBuilder().Tag("img", null, new { src = url });
        }