<commit_before>﻿using System;
using System.Collections.Generic;
using Gate.Builder.Loader;
using Gate.Owin;
using System.Linq;

namespace Gate.Builder
{
    using AppAction = Action< // app
       IDictionary<string, object>, // env
       Action< // result
           string, // status
           IDictionary<string, string>, // headers
           Func< // body
               Func< // next
                   ArraySegment<byte>, // data
                   Action, // continuation
                   bool>, // async
               Action<Exception>, // error
               Action, // complete
               Action>>, // cancel
       Action<Exception>>; // error

    public class AppBuilder : IAppBuilder
    {
        public static AppDelegate BuildConfiguration()
        {
            return BuildConfiguration(default(string));
        }

        public static AppDelegate BuildConfiguration(string startupName)
        {
            var startup = new StartupLoader().Load(startupName);
            return BuildConfiguration(startup);
        }

        public static AppDelegate BuildConfiguration(Action<IAppBuilder> startup)
        {
            if (startup == null)
                throw new ArgumentNullException("startup");

            var builder = new AppBuilder();
            startup(builder);
            return builder.Materialize();
        }

        readonly IList<Delegate> _stack;

        public AppBuilder()
        {
            _stack = new List<Delegate>();
            AddAdapter<AppDelegate, AppAction>(Adapters.ToAction);
            AddAdapter<AppAction, AppDelegate>(Adapters.ToDelegate);
            AddAdapter<AppDelegate, AppTaskDelegate>(Adapters.ToApp);
            AddAdapter<AppTaskDelegate, AppDelegate>(Adapters.ToDelegate);
        }

        public IAppBuilder Use<TApp>(Func<TApp, TApp> middleware)
        {
            _stack.Add(middleware);
            return this;
        }

        public TApp Build<TApp>(Action<IAppBuilder> fork)
        {
            var b = new AppBuilder();
            fork(b);
            return b.Materialize<TApp>();<commit_msg>Adding additional pair of adapters<commit_after>﻿using System;
using System.Collections.Generic;
using Gate.Builder.Loader;
using Gate.Owin;
using System.Linq;

namespace Gate.Builder
{
    using AppAction = Action< // app
       IDictionary<string, object>, // env
       Action< // result
           string, // status
           IDictionary<string, string>, // headers
           Func< // body
               Func< // next
                   ArraySegment<byte>, // data
                   Action, // continuation
                   bool>, // async
               Action<Exception>, // error
               Action, // complete
               Action>>, // cancel
       Action<Exception>>; // error

    public class AppBuilder : IAppBuilder
    {
        public static AppDelegate BuildConfiguration()
        {
            return BuildConfiguration(default(string));
        }

        public static AppDelegate BuildConfiguration(string startupName)
        {
            var startup = new StartupLoader().Load(startupName);
            return BuildConfiguration(startup);
        }

        public static AppDelegate BuildConfiguration(Action<IAppBuilder> startup)
        {
            if (startup == null)
                throw new ArgumentNullException("startup");

            var builder = new AppBuilder();
            startup(builder);
            return builder.Materialize();
        }

        readonly IList<Delegate> _stack;

        public AppBuilder()
        {
            _stack = new List<Delegate>();
            AddAdapter<AppDelegate, AppAction>(Adapters.ToAction);
            AddAdapter<AppAction, AppDelegate>(Adapters.ToDelegate);
            AddAdapter<AppDelegate, AppTaskDelegate>(Adapters.ToTaskDelegate);
            AddAdapter<AppTaskDelegate, AppDelegate>(Adapters.ToDelegate);
            AddAdapter<AppAction, AppTaskDelegate>(app => Adapters.ToTaskDelegate(Adapters.ToDelegate(app)));
            AddAdapter<AppTaskDelegate, AppAction>(app => Adapters.ToAction(Adapters.ToDelegate(app)));
        }

        public IAppBuilder Use<TApp>(Func<TApp, TApp> middleware)
        {
            _stack.Add(middleware);
            return this;
        }

        public TApp Build<TApp>(Action<IAppBuilder> fork)
        {
            var b = new AppBuilder();
            fork(b);
            return b.Materialize<TApp>();
{'fraction_non_alphanumeric': 0.0967741935483871, 'fraction_numerical': 0.0, 'mean_word_length': 1.8974691758598312, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7196551', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1061, 'n_words': 245}