yavsc/Yavsc/Helpers/HtmlHelpers.cs

22 lines
693 B
C#
Raw Normal View History

2017-02-12 03:53:33 +01:00
using System;
2017-05-16 02:16:09 +02:00
using Microsoft.AspNet.Http;
2017-02-12 03:53:33 +01:00
using Microsoft.AspNet.Mvc.Rendering;
using Yavsc.Models.Drawing;
namespace Yavsc.Helpers
{
public static class HtmlHelpers
{
public static HtmlString Color(this Color c)
{
if (c==null) return new HtmlString("#000");
return new HtmlString(String.Format("#{0:X2}{1:X2}{2:X2}", c.Red, c.Green, c.Blue));
}
2017-05-16 02:16:09 +02:00
public static string ToAbsolute(this HttpRequest request, string url)
{
var host = request.Host;
var isSecure = request.Headers[Constants.SshHeaderKey]=="on";
return (isSecure ? "https" : "http") + $"://{host}/{url}";
}
2017-02-12 03:53:33 +01:00
}
2017-05-16 02:16:09 +02:00
}