This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// <see cref="DelegatingHandler"/> that can be used to capture the actual outbound request and the returned | |
| /// response. These are logged by default to the console but can also be routed to an action. This can be useful | |
| /// for tests that use a <see cref="HttpClient"/> to call a fake service. | |
| /// </summary> | |
| /// <example> | |
| /// new HttpClient(new LoggingDelegatingHandler(new HttpClientHandler())); | |
| /// </example> | |
| public class LoggingDelegatingHandler : DelegatingHandler | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BufferedTextWriterSink : ILogEventSink, IDisposable | |
| { | |
| private readonly LogEventLevel? standardErrorFromLevel; | |
| private readonly ITextFormatter formatter; | |
| private readonly object _syncRoot = new(); | |
| private readonly TextWriter standardWriter; | |
| private readonly TextWriter errorWriter; | |
| private readonly ConcurrentBag<LogEvent> logEvents = new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| logger.LogInformation($"We can now do this {someCode}"); | |
| logger.LogInformation($"And this {1 + 1:Calculated}"); | |
| logger.LogInformation($"And also this {() => ExpensiveMethodCall(TimeSpan.FromSeconds(1)):Expensive}"); | |
| logger.LogInformation($"And not worry about {UnsafeMethodCall:Unsafe}"); | |
| logger.LogTrace($"And not have to check if the log level is enabled {() => ExpensiveMethodCall(TimeSpan.FromSeconds(10)):Expensive}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static class TypeExtensions | |
| { | |
| public static IEnumerable<Type> GetInstanceTypesImplementing<T>( | |
| this Assembly assembly, params Assembly[] assemblies) | |
| { | |
| var serviceType = typeof(T); | |
| return assemblies.Union(new [] { assembly }).SelectMany(x => x.GetTypes()) | |
| .Where( x => x.IsClass && !x.IsAbstract && serviceType.IsAssignableFrom( x ) ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| board = [ | |
| [None, None, None], | |
| [None, None, None], | |
| [None, None, None] | |
| ] | |
| def available_goes(): | |
| return len([item for item in [x for sublist in [board[0], board[1], board[2]] for x in sublist] if item is None]) > 0 | |
| def set_position(player, x, y): |
OlderNewer