Skip to content

Instantly share code, notes, and snippets.

View FSou1's full-sized avatar
:octocat:

Maxim Zhukov FSou1

:octocat:
View GitHub Profile
<?xml version="1.0"?>
<appSettings>
<!-- This line responsible for nhibernate logging -->
<add key="nhibernate-logger" value="NHibernate.Logging.CommonLogging.CommonLoggingLoggerFactory, NHibernate.Logging.CommonLogging" />
</appSettings>
public abstract class ScenarioRunner<T> : IScenarioRunner<T> where T : ScenarioBase
{
protected ScenarioRunner(
ISession session,
IScenarioService<T> scenarioService,
IScenarioBrokerService brokerService)
{
_session = session;
_scenarioService = scenarioService;
_brokerService = brokerService;
public class ResponseInterceptorMiddleware
{
public ResponseInterceptorMiddleware(
Func<IDictionary<string, object>, Task> next,
string exceptionFormat
)
{
_next = next;
_exceptionFormat = exceptionFormat;
}
public class NamespaceHttpControllerSelector : IHttpControllerSelector
{
private const string NamespaceKey = "namespace";
private const string ControllerKey = "controller";
private readonly HttpConfiguration _configuration;
private readonly Lazy<Dictionary<string, HttpControllerDescriptor>> _controllers;
private readonly HashSet<string> _duplicates;
public NamespaceHttpControllerSelector(HttpConfiguration config)
public class PassthroughHandler : ExceptionHandler
{
public override void Handle(ExceptionHandlerContext context)
{
var info = ExceptionDispatchInfo.Capture(context.Exception);
info.Throw();
}
}
@FSou1
FSou1 / HttpPropertyKeys.cs
Last active January 13, 2017 10:46
Simple uptime monitoring owin's middleware (just for catching "<url>/uptime" requests)
public static class HttpPropertyKeys
{
public static readonly string UptimeMiddlewarePath = "/uptime";
}
// Implementation of custom NHibernate type, that helps to store and retrive JSON format
// JsonFormatter - static class with Serialize/Deserialize methods (with JsonConvert implementation for example)
namespace Tm.NHibernate.Types
{
public class JsonMappableType<T> : IUserType where T : class
{
public new bool Equals(object x, object y)
{
if (x == null && y == null)
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
const string response = @"
public void DifferentScopes(int arg)
{
Func<int, Func<int>> preventClosure = (val) => () => val;
{
int local = 42;
Func<int> a = () => preventClosure(local)();
Func<int> b = () => preventClosure(local)();
}
public class HttpClientProxy : IHttpClientProxy
{
private static readonly HttpClient client = new HttpClient();
private readonly PolicyWrap<HttpResponseMessage> policy;
public HttpClientProxy()
{
RetryPolicy<HttpResponseMessage> waitAndRetryPolicy = Policy
.HandleResult<HttpResponseMessage>(e => e.StatusCode == HttpStatusCode.RequestTimeout)
.WaitAndRetryAsync(