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

namespace Metrolib
{
	/// <summary>
	///     Base class for any bootstrapper to get the application running.
	/// </summary>
	/// <remarks>
	///     Responsible for:
	///     - Loading assemblies from embedded resources
	///     - (Live) Auto updating (TODO)
	/// </remarks>
	public class AbstractBootstrapper
	{
		private static string _containingAssembly;

		/// <summary>
		/// Allows 3rd party assemblies to be resolved from an embedded resources in the given assembly under
		/// %Assembly%\ThirdParty\
		/// </summary>
		/// <param name="containingAssembly"></param>
		protected static void EnableEmbeddedDependencyLoading(string containingAssembly)
		{
			_containingAssembly = containingAssembly;
			AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
		}

		private static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
		{
			string name = args.Name;

			var assemblyName = new AssemblyName(name);
			string fileName = assemblyName.Name;

			string resource = string.Format("{0}.ThirdParty.{1}.dll", _containingAssembly, fileName);
			Assembly curAsm = Assembly.GetExecutingAssembly();
			using (Stream stream = curAsm.GetManifestResourceStream(resource))
			{
				if (stream == null)
					return null;

				byte[] data = ReadFully(stream);
				return Assembly.Load(data);
			}
		}

		private static byte[] ReadFully(Stream input)
		{
			var buffer = new byte[16*1024];
			using (var ms = new MemoryStream())
			{
				int read;
				while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
				{
					ms.Write(buffer, 0, read);
				}
				return ms.ToArray();
			}
		}
	}
}<commit_msg>Folder from which embedded assemblies are loaded can be specified<commit_after>﻿using System;
using System.IO;
using System.Reflection;

namespace Metrolib
{
	/// <summary>
	///     Base class for any bootstrapper to get the application running.
	/// </summary>
	/// <remarks>
	///     Responsible for:
	///     - Loading assemblies from embedded resources
	///     - (Live) Auto updating (TODO)
	/// </remarks>
	public class AbstractBootstrapper
	{
		private static string _containingAssembly;
		private static string _subFolder;

		/// <summary>
		/// Allows 3rd party assemblies to be resolved from an embedded resources in the given assembly under
		/// %Assembly%\%subfolder%\
		/// </summary>
		/// <param name="containingAssembly"></param>
		/// <param name="subFolder"></param>
		protected static void EnableEmbeddedDependencyLoading(string containingAssembly, string subFolder)
		{
			_containingAssembly = containingAssembly;
			_subFolder = subFolder;

			AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
		}

		private static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
		{
			string name = args.Name;

			var assemblyName = new AssemblyName(name);
			string fileName = assemblyName.Name;

			string resource = string.Format("{0}.{1}.{2}.dll", _containingAssembly, _subFolder, fileName);
			Assembly curAsm = Assembly.GetExecutingAssembly();
			using (Stream stream = curAsm.GetManifestResourceStream(resource))
			{
				if (stream == null)
					return null;

				byte[] data = ReadFully(stream);
				return Assembly.Load(data);
			}
		}

		private static byte[] ReadFully(Stream input)
		{
			var buffer = new byte[16*1024];
			using (var ms = new MemoryStream())
			{
				int read;
				while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
				{
					ms.Write(buffer, 0, read);
				}
				return ms.ToArray();
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.11850603762987924, 'fraction_numerical': 0.007020499859590003, 'mean_word_length': 3.338611449451888, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '6590483', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1023, 'n_words': 292}