Skip to content

Instantly share code, notes, and snippets.

View maftieu's full-sized avatar

Mathieu maftieu

View GitHub Profile
@maftieu
maftieu / NLogExtensions.cs
Created November 25, 2015 09:42
NLog extensions
public static class NLogExtensions
{
public static void WarnIf(this NLog.ILogger @this, bool condition, string message)
{
if (condition && @this.IsWarnEnabled)
{
@this.Warn(message);
}
}
@maftieu
maftieu / CacheHelper.cs
Created January 11, 2016 09:11
ASP.Net Cache helper
/// <summary>
/// Implements a cache helper.
/// Taken from http://codereview.stackexchange.com/questions/25907/asp-net-caching-helper (comments added).
/// </summary>
public static class CacheHelper
{
/// <summary>
/// Retrieve the specified item from the cache if it is cached. Otherwise, insert it to the cache.
/// Note: of the cache is not available, the <paramref name="initializer"/> method may be called on every call.
/// </summary>