// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; namespace Microsoft.AspNet.Mvc { public class TestSink { public TestSink( Func writeEnabled = null, Func beginEnabled = null) { WriteEnabled = writeEnabled; BeginEnabled = beginEnabled; Scopes = new List(); Writes = new List(); } public Func WriteEnabled { get; set; } public Func BeginEnabled { get; set; } public List Scopes { get; set; } public List Writes { get; set; } public void Write(WriteContext context) { if (WriteEnabled == null || WriteEnabled(context)) { Writes.Add(context); } } public void Begin(BeginScopeContext context) { if (BeginEnabled == null || BeginEnabled(context)) { Scopes.Add(context); } } public static bool EnableWithTypeName(WriteContext context) { return context.LoggerName.Equals(typeof(T).FullName); } public static bool EnableWithTypeName(BeginScopeContext context) { return context.LoggerName.Equals(typeof(T).FullName); } } }