<commit_before>﻿using DancingGoat.Models;
using KenticoCloud.Delivery;
using System.Configuration;
using System.Web.Mvc;
using DancingGoat.InlineContentItemResolver;

namespace DancingGoat.Controllers
{
    public class ControllerBase : AsyncController
    {
        protected readonly DeliveryClient client = new DeliveryClient(ConfigurationManager.AppSettings["ProjectId"]);

        public ControllerBase()
        {
            client.CodeFirstModelProvider.TypeProvider = new CustomTypeProvider();
            client.ContentLinkUrlResolver = new CustomContentLinkUrlResolver();
            client.InlineContentItemsProcessor.RegisterTypeResolver(new HostedVideoResolver());
            client.InlineContentItemsProcessor.RegisterTypeResolver(new TweetResolver());
        }
    }
}<commit_msg>CMP-363 - Make DeliveryClient static for better performance, use PreviewToken from web.config as per instructions<commit_after>﻿using DancingGoat.Models;
using KenticoCloud.Delivery;
using System.Configuration;
using System.Web.Mvc;
using DancingGoat.InlineContentItemResolver;

namespace DancingGoat.Controllers
{
    public class ControllerBase : AsyncController
    {
        protected static readonly DeliveryClient client = CreateDeliveryClient();

        public static DeliveryClient CreateDeliveryClient()
        {
            var previewToken = ConfigurationManager.AppSettings["PreviewToken"];
            var projectId = ConfigurationManager.AppSettings["ProjectId"];

            var clientInstance = 
                !string.IsNullOrEmpty(previewToken) ? 
                    new DeliveryClient(projectId, previewToken) : 
                    new DeliveryClient(projectId);

            clientInstance.CodeFirstModelProvider.TypeProvider = new CustomTypeProvider();
            clientInstance.ContentLinkUrlResolver = new CustomContentLinkUrlResolver();
            clientInstance.InlineContentItemsProcessor.RegisterTypeResolver(new HostedVideoResolver());
            clientInstance.InlineContentItemsProcessor.RegisterTypeResolver(new TweetResolver());

            return clientInstance;
        }
    }
}
{'fraction_non_alphanumeric': 0.06836397925506836, 'fraction_numerical': 0.0014144271570014145, 'mean_word_length': 3.6433260393873086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5438096', 'n_tokens_mistral': 492, 'n_tokens_neox': 481, 'n_words': 99}