Browse Source

Cleanup of unused console classes

Bepis 6 years ago
parent
commit
1decfc61d7
3 changed files with 0 additions and 120 deletions
  1. 0 2
      BepInEx/BepInEx.csproj
  2. 0 84
      BepInEx/ConsoleUtil/ConsoleMirror.cs
  3. 0 34
      BepInEx/ConsoleUtil/Extensions.cs

+ 0 - 2
BepInEx/BepInEx.csproj

@@ -59,9 +59,7 @@
     <Compile Include="ConsoleUtil\ConsoleEncoding\ConsoleEncoding.Buffers.cs" />
     <Compile Include="ConsoleUtil\ConsoleEncoding\ConsoleEncoding.cs" />
     <Compile Include="ConsoleUtil\ConsoleEncoding\ConsoleEncoding.PInvoke.cs" />
-    <Compile Include="ConsoleUtil\ConsoleMirror.cs" />
     <Compile Include="ConsoleUtil\ConsoleWindow.cs" />
-    <Compile Include="ConsoleUtil\Extensions.cs" />
     <Compile Include="ConsoleUtil\Kon.cs" />
     <Compile Include="ConsoleUtil\SafeConsole.cs" />
     <Compile Include="Bootstrap\Chainloader.cs" />

+ 0 - 84
BepInEx/ConsoleUtil/ConsoleMirror.cs

@@ -1,84 +0,0 @@
-// --------------------------------------------------
-// UnityInjector - ConsoleMirror.cs
-// Copyright (c) Usagirei 2015 - 2015
-// --------------------------------------------------
-
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Text;
-
-namespace UnityInjector.ConsoleUtil
-{
-    internal class ConsoleMirror : IDisposable
-    {
-        private readonly MirrorWriter _tWriter;
-
-        public ConsoleMirror(string path)
-        {
-            try
-            {
-                var fileStream = File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Read);
-                var fileWriter = new StreamWriter(fileStream)
-                {
-                    AutoFlush = true
-                };
-                _tWriter = new MirrorWriter(fileWriter, Console.Out);
-            }
-            catch (Exception e)
-            {
-                SafeConsole.ForegroundColor = ConsoleColor.DarkGray;
-                Console.WriteLine("Couldn't open file to write: {0}", Path.GetFileName(path));
-                Console.WriteLine(e.Message);
-                SafeConsole.ForegroundColor = ConsoleColor.Gray;
-
-                return;
-            }
-            Console.SetOut(_tWriter);
-
-            Console.WriteLine();
-
-            var processName = Process.GetCurrentProcess().ProcessName;
-            var now = DateTime.Now;
-
-            Console.WriteLine($" {processName} - {now:dd-MM-yyyy hh:mm:ss} ".PadCenter(79, '='));
-            Console.WriteLine();
-        }
-
-        public void Dispose()
-        {
-            var cOld = _tWriter.Console;
-            var fOld = _tWriter.File;
-            Console.SetOut(cOld);
-            if (fOld == null)
-                return;
-            fOld.Flush();
-            fOld.Close();
-        }
-
-        private class MirrorWriter : TextWriter
-        {
-            public TextWriter Console { get; }
-            public override Encoding Encoding => File.Encoding;
-            public TextWriter File { get; }
-
-            public MirrorWriter(TextWriter file, TextWriter console)
-            {
-                File = file;
-                Console = console;
-            }
-
-            public override void Flush()
-            {
-                File.Flush();
-                Console.Flush();
-            }
-
-            public override void Write(char value)
-            {
-                File.Write(value);
-                Console.Write(value);
-            }
-        }
-    }
-}

+ 0 - 34
BepInEx/ConsoleUtil/Extensions.cs

@@ -1,34 +0,0 @@
-// --------------------------------------------------
-// UnityInjector - Extensions.cs
-// Copyright (c) Usagirei 2015 - 2015
-// --------------------------------------------------
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text.RegularExpressions;
-
-namespace UnityInjector
-{
-    internal static class Extensions
-    {
-        public static string PluginsPath { get; } = Path.Combine(Environment.CurrentDirectory, "UnityInjector");
-        public static string UserDataPath { get; } = Path.Combine(PluginsPath, "Config");
-        public static string Asciify(this string s) => Regex.Replace(s, @"[^0-9A-Za-z]", "_");
-        public static string CombinePaths(params string[] parts) => parts.Aggregate(Path.Combine);
-
-        public static void ForEach<T>(this IEnumerable<T> tees, Action<T> action)
-        {
-            foreach (var tee in tees)
-                action(tee);
-        }
-
-        public static string PadCenter(this string str, int totalWidth, char paddingChar = ' ')
-        {
-            int spaces = totalWidth - str.Length;
-            int padLeft = spaces / 2 + str.Length;
-            return str.PadLeft(padLeft, paddingChar).PadRight(totalWidth, paddingChar);
-        }
-    }
-}