<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;

namespace Microsoft.TeamFoundation.Authentication
{
    public sealed class Configuration
    {
        private const char HostSplitCharacter = '.';

        public Configuration(string directory)
        {
            if (String.IsNullOrWhiteSpace(directory))
                throw new ArgumentNullException("currentDirectory");
            if (!Directory.Exists(directory))
                throw new DirectoryNotFoundException(directory);

            _values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

            LoadGitConfiguation(directory);
        }

        public Configuration()
            : this(Environment.CurrentDirectory)
        { }

        private readonly Dictionary<string, string> _values;

        public string this[string key]
        {
            get { return _values[key]; }
        }

        public bool ContainsKey(string key)
        {
            return _values.ContainsKey(key);
        }

        public bool TryGetEntry(string prefix, string key, string suffix, out Entry entry)
        {
            Debug.Assert(prefix != null, "The prefix parameter is null");
            Debug.Assert(suffix != null, "The suffic parameter is null");

            string match = String.IsNullOrEmpty(key)
                ? String.Format("{0}.{1}", prefix, suffix)
                : String.Format("{0}.{1}.{2}", prefix, key, suffix);

            // if there's a match, return it
            if (_values.ContainsKey(match))
            {
                entry = new Entry(match, _values[match]);<commit_msg>Field initializes itself + ctor for unit tests.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;

namespace Microsoft.TeamFoundation.Authentication
{
    public sealed class Configuration
    {
        private const char HostSplitCharacter = '.';

        public Configuration(string directory)
        {
            if (String.IsNullOrWhiteSpace(directory))
                throw new ArgumentNullException("currentDirectory");
            if (!Directory.Exists(directory))
                throw new DirectoryNotFoundException(directory);

            LoadGitConfiguation(directory);
        }

        public Configuration()
            : this(Environment.CurrentDirectory)
        { }

        internal Configuration(TextReader configReader)
        {
            ParseGitConfig(configReader, _values);
        }

        private readonly Dictionary<string, string> _values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

        public string this[string key]
        {
            get { return _values[key]; }
        }

        public bool ContainsKey(string key)
        {
            return _values.ContainsKey(key);
        }

        public bool TryGetEntry(string prefix, string key, string suffix, out Entry entry)
        {
            Debug.Assert(prefix != null, "The prefix parameter is null");
            Debug.Assert(suffix != null, "The suffic parameter is null");

            string match = String.IsNullOrEmpty(key)
                ? String.Format("{0}.{1}", prefix, suffix)
                : String.Format("{0}.{1}.{2}", prefix, key, suffix);

            // if there's a match, return it
            if (_values.ContainsKey(match))
            {
                entry = new Entry(match, _values[match]);
{'fraction_non_alphanumeric': 0.09452595936794582, 'fraction_numerical': 0.0028216704288939053, 'mean_word_length': 2.2256596906278436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4260756', 'n_tokens_mistral': 868, 'n_tokens_neox': 834, 'n_words': 221}