I hereby claim:
- I am sebnilsson on github.
- I am sebnilsson (https://keybase.io/sebnilsson) on keybase.
- I have a public key ASCWYybMp3SXcq0oy9xFjsdWBwizgfPCOEE1sCL7ke-Gmwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
[HtmlTargetElement("html-encode", TagStructure = TagStructure.NormalOrSelfClosing)] | |
public class HtmlEncodeTagHelper : TagHelper | |
{ | |
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) | |
{ | |
var childContent = output.Content.IsModified | |
? output.Content.GetContent() | |
: (await output.GetChildContentAsync()).GetContent(); | |
string encodedChildContent = WebUtility.HtmlEncode(childContent ?? string.Empty); |
public static class HashAlgorithmExtensions | |
{ | |
private const int BufferSize = 4096; | |
public static async Task<byte[]> ComputeHashAsync(this HashAlgorithm hash, Stream inputStream) | |
{ | |
if (hash == null) throw new ArgumentNullException(nameof(hash)); | |
if (inputStream == null) throw new ArgumentNullException(nameof(inputStream)); | |
hash.Initialize(); |
public static void Main(string[] args) | |
{ | |
var components = RegisterComponents(); | |
Run(components); | |
} | |
private static IContainer RegisterComponents() | |
{ | |
var builder = new ContainerBuilder(); |
public static class DateTimeRfc3339Extensions | |
{ | |
public static string ToRfc3339String(this DateTime dateTime) | |
{ | |
string rfc3339 = dateTime.ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz", DateTimeFormatInfo.InvariantInfo); | |
return rfc3339; | |
} | |
} |
public static class RouteCollectionAreasExtensions | |
{ | |
public static Route MapAreaRoute( | |
this RouteCollection routes, | |
string areaName, | |
string routeName, | |
string url, | |
object defaults = null, | |
object constraints = null, | |
string[] namespaces = null) |
public static string ToRelative(this Uri uri) | |
{ | |
if (uri == null) | |
{ | |
throw new ArgumentNullException(nameof(uri)); | |
} | |
return uri.IsAbsoluteUri ? uri.PathAndQuery : uri.OriginalString; | |
} |
public static HttpContext GetFakeHttpContext( | |
string url, | |
HttpRequest request = null, | |
HttpResponse response = null) | |
{ | |
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) | |
{ | |
throw new ArgumentOutOfRangeException("url", "The URL must be a well-formed absolute URI."); | |
} |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] | |
public class SuppressXFrameOptionsHeaderAttribute : ActionFilterAttribute | |
{ | |
public override void OnResultExecuted(ResultExecutedContext filterContext) | |
{ | |
filterContext.HttpContext.Response.Headers.Set("X-Frame-Options", "ALLOWALL"); | |
} | |
} |
public static ExpandoObject ToDynamic(this object obj) | |
{ | |
var expandoObject = new ExpandoObject(); | |
if (obj == null) | |
{ | |
return expandoObject; | |
} | |
var dictionaryValues = new RouteValueDictionary(obj); | |
if (!dictionaryValues.Any()) |