<commit_before>//
// Copyright (C) 2012 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Linq;
using System.Collections.Generic;
using System.Dynamic;
using System.Reflection;
using System.IO;

using JsonFx;
using JsonFx.Json;
using System.Text.RegularExpressions;

namespace JsonConfig 
{
	public static class Config {
		public static dynamic Default = new ConfigObject ();
		public static dynamic User = new ConfigObject ();

		public static dynamic MergedConfig {
			get {
				return Merger.Merge (User, Default);
			}
		}

		public static string defaultEnding = ".conf";

		private static dynamic global_config;
		public static dynamic Global {
			get {
				if (global_config == null) {
					global_config = MergedConfig;
				}
				return global_config;
			}
			set {
				global_config = Merger.Merge (value, MergedConfig);
			}
		}
	
		/// <summary>
		/// Gets a ConfigObject that represents the current configuration. Since it is 
		/// a cloned copy, changes to the underlying configuration files that are done
		/// after GetCurrentScope() is called, are not applied in the returned instance.
		/// </summary>
		public static ConfigObject GetCurrentScope () {
			if (Global is NullExceptionPreventer)
				return new ConfigObject ();
			else
				return Global.Clone ();
		}

		public delegate void UserConfigFileChangedHandler ();
		public static event UserConfigFileChangedHandler OnUserConfigFileChanged;

		static Config ()
		{
			// static C'tor, run once to check for compiled/embedded config

			// scan ALL linked assemblies and merge their default configs
			var assemblies = AppDomain.CurrentDomain.GetAssemblies();
            foreach (dynamic conf in assemblies.Select(assembly => GetDefaultConfig(assembly))) {
                Default = Merger.Merge(conf, Default);
            }

			// User config (provided through a settings.conf file)
			var execution_path = AppDomain.CurrentDomain.BaseDirectory;
			var user_config_filename = "settings";

			// TODO this is ugly but makes life easier
			// TODO not windows compatible
			if (execution_path.EndsWith ("/bin/Debug/")) {<commit_msg>fixed spacing<commit_after>//
// Copyright (C) 2012 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Linq;
using System.Collections.Generic;
using System.Dynamic;
using System.Reflection;
using System.IO;

using JsonFx;
using JsonFx.Json;
using System.Text.RegularExpressions;

namespace JsonConfig 
{
	public static class Config {
		public static dynamic Default = new ConfigObject ();
		public static dynamic User = new ConfigObject ();

		public static dynamic MergedConfig {
			get {
				return Merger.Merge (User, Default);
			}
		}

		public static string defaultEnding = ".conf";

		private static dynamic global_config;
		public static dynamic Global {
			get {
				if (global_config == null) {
					global_config = MergedConfig;
				}
				return global_config;
			}
			set {
				global_config = Merger.Merge (value, MergedConfig);
			}
		}
	
		/// <summary>
		/// Gets a ConfigObject that represents the current configuration. Since it is 
		/// a cloned copy, changes to the underlying configuration files that are done
		/// after GetCurrentScope() is called, are not applied in the returned instance.
		/// </summary>
		public static ConfigObject GetCurrentScope () {
			if (Global is NullExceptionPreventer)
				return new ConfigObject ();
			else
				return Global.Clone ();
		}

		public delegate void UserConfigFileChangedHandler ();
		public static event UserConfigFileChangedHandler OnUserConfigFileChanged;

		static Config ()
		{
			// static C'tor, run once to check for compiled/embedded config

			// scan ALL linked assemblies and merge their default configs
			var assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (dynamic conf in assemblies.Select(assembly => GetDefaultConfig(assembly))) {
				Default = Merger.Merge(conf, Default);
			}

			// User config (provided through a settings.conf file)
			var execution_path = AppDomain.CurrentDomain.BaseDirectory;
			var user_config_filename = "settings";

			// TODO this is ugly but makes life easier
			// TODO not windows compatible
			if (execution_path.EndsWith ("/bin/Debug/")) {
{'fraction_non_alphanumeric': 0.07984790874524715, 'fraction_numerical': 0.0012674271229404308, 'mean_word_length': 3.581277213352685, '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': '6845713', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1581, 'n_words': 715}