<commit_before>﻿using System;
using System.Reflection;
using SemVersion;

namespace Hakudu.Bootstrapper
{
    public class BootstrapperContext
    {
        public string Name { get; }
        public SemanticVersion Version { get; }
        public string Copyright { get; }
        public string Website { get; }

        public string UserAgent { get; }

        public KuduEnvironment Environment { get; }
        public bool IsKuduEnvironment => Environment != null;

        public BootstrapperContext()
        {
            SemanticVersion version;
            if (!SemanticVersion.TryParse(GetAssemblyVersion(), out version))
                throw new Exception("Unable to determine the bootstrapper's version.");

            Name = GetAssemblyTitle();
            Version = version;
            Copyright = GetAssemblyCopyright();
            Website = "http://hakudu.io";

            UserAgent = $"Hakudu.Bootstrapper/{Version}";

            Environment = KuduEnvironment.GetIfExecutedInKudu();
        }

        static string GetAssemblyVersion()
        {
            var assembly = Assembly.GetEntryAssembly();
            var versionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
            return versionAttribute?.InformationalVersion;
        }

        static string GetAssemblyTitle()
        {
            var assembly = Assembly.GetEntryAssembly();
            var titleAttribute = assembly.GetCustomAttribute<AssemblyTitleAttribute>();
            return titleAttribute?.Title;
        }

        static string GetAssemblyCopyright()
        {
            var assembly = Assembly.GetEntryAssembly();
            var copyrightAttribute = assembly.GetCustomAttribute<AssemblyCopyrightAttribute>();
            return copyrightAttribute?.Copyright;
        }
    }<commit_msg>Provide a path to bootstrapper exe file in BoostrapperContext<commit_after>﻿using System;
using System.Reflection;
using SemVersion;

namespace Hakudu.Bootstrapper
{
    public class BootstrapperContext
    {
        static readonly Assembly _assembly = Assembly.GetExecutingAssembly();

        public string Name { get; }
        public SemanticVersion Version { get; }
        public string Copyright { get; }
        public string Website { get; } = "http://hakudu.io";

        public string UserAgent { get; }
        public string ExePath { get; }

        public KuduEnvironment Environment { get; }
        public bool IsKuduEnvironment => Environment != null;

        public BootstrapperContext()
        {
            SemanticVersion version;
            if (!SemanticVersion.TryParse(GetAssemblyVersion(), out version))
                throw new Exception("Unable to determine the bootstrapper's version.");

            Name = GetAssemblyTitle();
            Version = version;
            Copyright = GetAssemblyCopyright();

            UserAgent = $"Hakudu.Bootstrapper/{Version}";
            ExePath = _assembly.Location;

            Environment = KuduEnvironment.GetIfExecutedInKudu();
        }

        static string GetAssemblyVersion()
        {
            var versionAttribute = _assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
            return versionAttribute?.InformationalVersion;
        }

        static string GetAssemblyTitle()
        {
            var titleAttribute = _assembly.GetCustomAttribute<AssemblyTitleAttribute>();
            return titleAttribute?.Title;
        }

        static string GetAssemblyCopyright()
        {
            var copyrightAttribute = _assembly.GetCustomAttribute<AssemblyCopyrightAttribute>();
            return copyrightAttribute?.Copyright;
        }
    }
{'fraction_non_alphanumeric': 0.07748577621240856, 'fraction_numerical': 0.0, 'mean_word_length': 2.384051329055912, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6638483', 'n_tokens_mistral': 853, 'n_tokens_neox': 827, 'n_words': 211}