Skip to content

Instantly share code, notes, and snippets.

View mattwcole's full-sized avatar

Matt Cole mattwcole

View GitHub Profile
@mattwcole
mattwcole / DisableSemanticLoggingDecorator.cs
Last active November 7, 2022 20:31
Microsoft.Extensions.Logging.ILogger decorator that disables semantic logging
public sealed class DisableSemanticLoggingDecorator : ILogger
{
private readonly ILogger _logger;
public DisableSemanticLoggingDecorator(ILogger logger) => _logger = logger;
public IDisposable BeginScope<TState>(TState state) => _logger.BeginScope(state);
public bool IsEnabled(LogLevel logLevel) => _logger.IsEnabled(logLevel);
using System;
using System.Threading.Tasks;
using Xunit;
namespace XunitParallel
{
public abstract class GasTests
{
private readonly WebDriver _driver;
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddFluentValidation(config =>
{
config.RegisterValidatorsFromAssemblyContaining<FooValidator>();
config.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
})
.ConfigureApiBehaviorOptions(options =>
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Extensions.Options;
namespace Gelf.Extensions.Logging.Samples.AspNetCore2
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace JsonFormat
{
public class Program
{
private const string InputData = @"{
using System;
using Autofac.Extras.Moq;
using Moq;
using NUnit.Framework;
namespace Sandbox
{
public class AutoMockFunctionTests
{
[Test]
using System;
using Moq;
namespace MoqDemo
{
public class Program
{
public static void Main()
{
var mockSqlUtility = new Mock<SqlUtility> {CallBase = true};
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace CancelSearch
{
class Program
{
static void Main()
@mattwcole
mattwcole / gist:5124b49cd9efec4bd7eb
Created June 22, 2015 20:03
C# HttpClient DeleteAsync() with Header
class Program
{
static void Main()
{
HttpAsync().Wait();
Console.ReadKey();
}
private static async Task HttpAsync()
{
@mattwcole
mattwcole / gist:65a8d5a1adb8179932ba
Last active August 29, 2015 14:23
Autofac Binding Examples
using System;
using Autofac;
namespace LinkedList
{
public class Program
{
static void Main()
{
var builder = new ContainerBuilder();