示例#1
0
        public string ToHtml(Talk talk, int number = -1)
        {
            var builder = new StringBuilder();

            if (number > 0)
            {
                builder.AppendLine($"<li value=\"{number}\">");
            }
            else
            {
                builder.AppendLine("<li>");
            }

            if (talk.Event != "")
            {
                builder.Append("  ");
                if (talk.EventHint != "")
                {
                    builder.Append(talk.EventHint + " ");
                }
                builder.Append(QuoteWithLink(talk, talk.Event, "event"));
                builder.AppendLine(",<br />");
            }

            if (talk.Title != "")
            {
                builder.Append("  ");
                builder.AppendLine(QuoteWithLink(talk, talk.Title, "talk"));
                if (talk.Lang != "")
                {
                    builder.AppendLine("    (" + talk.Lang.ToUpperInvariant() + ")");
                }
                foreach (var link in talk.Links)
                {
                    if (link.Key != "event" && link.Key != "talk")
                    {
                        builder.AppendLine("    " + link.ToHtml());
                    }
                }

                builder.AppendLine("  ,<br />");
            }

            var details = new List <string>();

            if (talk.Date != null)
            {
                var dateStr = talk.Date.Value.ToString(dateFormat, new CultureInfo(culture));
                if (talk.Date2 != null)
                {
                    dateStr += " – " + talk.Date2.Value.ToString(dateFormat, new CultureInfo(culture));
                }
                details.Add(dateStr);
            }
            else
            {
                details.Add(talk.Year.ToString());
            }

            if (talk.Location != null)
            {
                details.Add(talk.Location.Replace("г. ", "г.&nbsp;"));
            }
            if (details.Any())
            {
                builder.AppendLine("  <i>" + string.Join(", ", details) + "</i>");
            }

            builder.AppendLine("</li>");

            return(builder.ToString());
        }