System.IO.TextWriter.Dispose()

Here are the examples of the csharp api System.IO.TextWriter.Dispose() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

509 Examples 7

19 View Source File : Program.cs
License : MIT License
Project Creator : 0xd4d

static void Disreplacedemble(DisasmJobContext context, DisasmJob job) {
			var (writer, disposeWriter) = job.GetTextWriter();
			try {
				var methods = job.Methods;
				Array.Sort(methods, SortMethods);
				for (int i = 0; i < methods.Length; i++) {
					if (i > 0)
						writer.WriteLine();

					var method = methods[i];
					context.Disreplacedembler.Disreplacedemble(context.Formatter, writer, method);
				}
			}
			finally {
				if (disposeWriter)
					writer.Dispose();
			}
		}

19 View Source File : SlnWriter.cs
License : MIT License
Project Creator : 3F

protected virtual void Dispose(bool _)
        {
            if(!disposed)
            {
                stream?.Dispose();

                disposed = true;
            }
        }

19 View Source File : Logging.cs
License : MIT License
Project Creator : actions

private void EndPage()
        {
            if (_pageWriter != null)
            {
                _pageWriter.Flush();
                _pageData.Flush();
                //The StreamWriter object calls Dispose() on the provided Stream object when StreamWriter.Dispose is called.
                _pageWriter.Dispose();
                _pageWriter = null;
                _pageData = null;
                _jobServerQueue.QueueFileUpload(_timelineId, _timelineRecordId, "DistributedTask.Core.Log", "CustomToolLog", _dataFileName, true);
            }
        }

19 View Source File : HostTraceListener.cs
License : MIT License
Project Creator : actions

public override void WriteLine(string message)
        {
            base.WriteLine(message);
            if (_enablePageLog)
            {
                int messageSize = UTF8Encoding.UTF8.GetByteCount(message);
                _currentPageSize += messageSize;
                if (_currentPageSize > _pageSizeLimit)
                {
                    Flush();
                    if (Writer != null)
                    {
                        Writer.Dispose();
                        Writer = null;
                    }

                    Writer = CreatePageLogWriter();
                    _currentPageSize = 0;
                }
            }

            Flush();
        }

19 View Source File : File.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public virtual void Dispose()
        {
            lock (locker)
            {
                textReader?.Dispose();
                textWriter?.Dispose();
                fileStream?.Dispose();
            }
        }

19 View Source File : GuiderImpl.cs
License : MIT License
Project Creator : agalasso

protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (sw != null)
                {
                    sw.Close();
                    sw.Dispose();
                    sw = null;
                }
                if (sr != null)
                {
                    sr.Close();
                    sr.Dispose();
                    sr = null;
                }
                if (tcpCli != null)
                {
                    Debug.WriteLine("Disconnect from phd2");
                    tcpCli.Close();
                    tcpCli = null;
                }
            }
        }

19 View Source File : TxtRecorder.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

private void WriteFile(string log, string type)
        {
            var writer = GetWriter(type);
            if (writer == null)
                return;
            try
            {
                writer.Size += log.Length;
                writer.Stream.WriteLine(log);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString(), $"TextRecorder.WriteFile->{type}");
                writer.Stream.Dispose();
                writer.Stream.Close();
                ResetFile(type, writer);
            }
        }

19 View Source File : TxtRecorder.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

private void DisposeWriters()
        {
            foreach (var info in _writers)
            {
                if (info.Value.Stream == null)
                    continue;
                info.Value.Stream.Flush();
                info.Value.Stream.Dispose();
            }
            _writers.Clear();
        }

19 View Source File : CommandLine.cs
License : GNU General Public License v3.0
Project Creator : akaAgar

public void Dispose()
        {
            BriefingRoomGenerator.Dispose();
            LogWriter.Dispose();
        }

19 View Source File : LocationLogWriter.cs
License : MIT License
Project Creator : alen-smajic

protected virtual void Dispose(bool disposeManagedResources)
		{
			if (!_disposed)
			{
				if (disposeManagedResources)
				{
					Debug.LogFormat("{0} locations logged", _lineCount);
					if (null != _textWriter)
					{
						_textWriter.Flush();
						_fileStream.Flush();
#if !NETFX_CORE
						_textWriter.Close();
#endif
						_textWriter.Dispose();
						_fileStream.Dispose();

						_textWriter = null;
						_fileStream = null;
					}
				}
				_disposed = true;
			}
		}

19 View Source File : BlockMining.cs
License : MIT License
Project Creator : alexanderdna

public void Dispose()
        {
            if (_headerStreamWriter != null)
            {
                _headerStreamWriter.Close();
                _headerStreamWriter.Dispose();
                _headerStreamWriter = null;

                _headerStream = null;
            }
        }

19 View Source File : NetworkPressureTests.cs
License : MIT License
Project Creator : aliyun

public void Dispose()
        {
            this.context.Client.DeleteLogStoreAsync(this.context.LogStoreName).Wait();
            this.Log($"LogStore [{this.context.LogStoreName}] deleted.");
            this.logWriter.Dispose();
        }

19 View Source File : FileLogger.cs
License : GNU General Public License v3.0
Project Creator : Alois-xx

public void Dispose()
        {
            lock (myLock)
            {
                myLog?.Dispose();
                myLog = null;
            }
        }

19 View Source File : CodeWriter.cs
License : MIT License
Project Creator : amerkoleci

public void Dispose()
        {
            EndBlock();
            _writer.Dispose();
        }

19 View Source File : Printer.cs
License : MIT License
Project Creator : andycb

protected virtual void Dispose(bool disposing)
        {
            if (this.isDisposed)
            {
                return;
            }

            if (disposing && this.printerConnection != null)
            {
                this.streamReader.Dispose();
                this.streamWriter.Dispose();
                this.printerConnection.Dispose();
            }

            this.isDisposed = true;
        }

19 View Source File : FileHelper.cs
License : Apache License 2.0
Project Creator : anjoy8

public static void WriteFile(string Path, string Strings)
        {
            if (!File.Exists(Path))
            {
                FileStream f = File.Create(Path);
                f.Close();
            }
            StreamWriter f2 = new StreamWriter(Path, false, System.Text.Encoding.GetEncoding("gb2312"));
            f2.Write(Strings);
            f2.Close();
            f2.Dispose();
        }

19 View Source File : FileHelper.cs
License : Apache License 2.0
Project Creator : anjoy8

public static void WriteFile(string Path, string Strings, Encoding encode)
        {
            if (!File.Exists(Path))
            {
                FileStream f = File.Create(Path);
                f.Close();
            }
            StreamWriter f2 = new StreamWriter(Path, false, encode);
            f2.Write(Strings);
            f2.Close();
            f2.Dispose();
        }

19 View Source File : FileHelper.cs
License : Apache License 2.0
Project Creator : anjoy8

public static void WriteFile(string Path, string Strings, Encoding encode)
        {
            if (!System.IO.File.Exists(Path))
            {
                System.IO.FileStream f = System.IO.File.Create(Path);
                f.Close();
            }
            System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, false, encode);
            f2.Write(Strings);
            f2.Close();
            f2.Dispose();
        }

19 View Source File : FileHelper.cs
License : Apache License 2.0
Project Creator : anjoy8

public static void WriteFile(string Path, string Strings)
        {
            if (!System.IO.File.Exists(Path))
            {
                System.IO.FileStream f = System.IO.File.Create(Path);
                f.Close();
            }
            System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, false, System.Text.Encoding.GetEncoding("gb2312"));
            f2.Write(Strings);
            f2.Close();
            f2.Dispose();
        }

19 View Source File : ChatLogWorker.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

public void Close()
        {
            lock (this.LogBuffer)
            {
                if (this.outputStream != null)
                {
                    this.outputStream.Flush();
                    this.outputStream.Close();
                    this.outputStream.Dispose();
                    this.outputStream = null;
                }
            }

            GC.Collect();
        }

19 View Source File : XIVLogPlugin.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

[MethodImpl(MethodImplOptions.NoInlining)]
        private void InitTask()
        {
            // FFXIV.Framework.config を読み込ませる
            lock (FFXIV.Framework.Config.ConfigBlocker)
            {
                _ = FFXIV.Framework.Config.Instance;
            }

            this.dumpLogTask = ThreadWorker.Run(
                doWork,
                TimeSpan.FromSeconds(Config.Instance.WriteInterval).TotalMilliseconds,
                "XIVLog Worker",
                ThreadPriority.Lowest);

            ActGlobals.oFormActMain.OnLogLineRead -= this.OnLogLineRead;
            ActGlobals.oFormActMain.OnLogLineRead += this.OnLogLineRead;

            void doWork()
            {
                var isNeedsFlush = false;

                if (string.IsNullOrEmpty(Config.Instance.OutputDirectory))
                {
                    Thread.Sleep(TimeSpan.FromSeconds(Config.Instance.WriteInterval));
                    return;
                }

                if (LogQueue.IsEmpty)
                {
                    if ((DateTime.Now - this.lastWroteTimestamp).TotalSeconds > 10)
                    {
                        this.lastWroteTimestamp = DateTime.MaxValue;
                        isNeedsFlush = true;
                    }
                    else
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(Config.Instance.WriteInterval));
                        return;
                    }
                }

                if ((DateTime.Now - this.lastFlushTimestamp).TotalSeconds
                    >= Config.Instance.FlushInterval)
                {
                    isNeedsFlush = true;
                }

                if (this.currentLogfileName != this.LogfileName)
                {
                    if (this.writter != null)
                    {
                        if (this.writeBuffer.Length > 0)
                        {
                            this.writter.Write(this.writeBuffer.ToString());
                            this.writeBuffer.Clear();
                        }

                        this.writter.Flush();
                        this.writter.Close();
                        this.writter.Dispose();
                    }

                    if (!Directory.Exists(Config.Instance.OutputDirectory))
                    {
                        Directory.CreateDirectory(Config.Instance.OutputDirectory);
                    }

                    this.writter = new StreamWriter(
                        new FileStream(
                            this.LogfileName,
                            FileMode.Append,
                            FileAccess.Write,
                            FileShare.Read),
                        new UTF8Encoding(false));
                    this.currentLogfileName = this.LogfileName;

                    this.RaisePropertyChanged(nameof(this.LogfileName));
                    this.RaisePropertyChanged(nameof(this.LogfileNameWithoutParent));
                }

                XIVLog.RefreshPCNameDictionary();

                while (LogQueue.TryDequeue(out XIVLog xivlog))
                {
                    if (this.currentZoneName != xivlog.ZoneName)
                    {
                        this.currentZoneName = xivlog.ZoneName;
                        this.wipeoutCounter = 1;
                        this.fileNo++;
                        isNeedsFlush = true;
                    }

                    if (StopLoggingKeywords.Any(x => xivlog.Log.Contains(x)))
                    {
                        this.wipeoutCounter++;
                        this.fileNo++;
                        isNeedsFlush = true;
                    }

                    this.writeBuffer.AppendLine(xivlog.ToCSVLine());
                    this.lastWroteTimestamp = DateTime.Now;
                    Thread.Yield();
                }

                if (isNeedsFlush ||
                    this.isForceFlush ||
                    this.writeBuffer.Length > 5000)
                {
                    if (this.writeBuffer.Length > 0)
                    {
                        this.writter.Write(this.writeBuffer.ToString());
                        this.writeBuffer.Clear();
                    }

                    if (isNeedsFlush || this.isForceFlush)
                    {
                        this.isForceFlush = false;
                        this.lastFlushTimestamp = DateTime.Now;
                        this.writter?.Flush();
                    }
                }
            }
        }

19 View Source File : XIVLogPlugin.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

[MethodImpl(MethodImplOptions.NoInlining)]
        private void EndTask()
        {
            ActGlobals.oFormActMain.OnLogLineRead -= this.OnLogLineRead;

            VideoCapture.Instance.FinishRecording();

            if (dumpLogTask != null)
            {
                this.dumpLogTask.Abort();
                this.dumpLogTask = null;
            }

            if (this.writter != null)
            {
                this.writter.Flush();
                this.writter.Close();
                this.writter.Dispose();
                this.writter = null;
            }
        }

19 View Source File : PrefixTextWriterTest.cs
License : MIT License
Project Creator : ap0llo

public void Dispose() => m_TextWriter.Dispose();

19 View Source File : TelnetAppender.cs
License : Apache License 2.0
Project Creator : apache

public void Dispose()
				{
					try
					{
						if (m_writer != null)
						{
							m_writer.Dispose();
							m_writer = null;
						}
					}
					catch { }

					if (m_socket != null)
					{
						try
						{
							m_socket.Shutdown(SocketShutdown.Both);
						}
						catch { }

						try
						{
#if NET_4_0 || NETSTANDARD
							m_socket.Dispose();
#else
							m_socket.Close();
#endif
						}
						catch { }

						m_socket = null;
					}
				}

19 View Source File : TextFileLogger.cs
License : Apache License 2.0
Project Creator : Appdynamics

public void Dispose()
        {
            _sw.Close(); 
            _sw.Dispose();
        }

19 View Source File : MetricSnapshotElasticsearchWriter.cs
License : Apache License 2.0
Project Creator : AppMetrics

protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _bulkPayload.Write(_textWriter);
#if !NETSTANDARD1_6
                _textWriter?.Close();
#endif
                _textWriter?.Dispose();
            }
        }

19 View Source File : HealthStatusTextWriter.cs
License : Apache License 2.0
Project Creator : AppMetrics

protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                #if NET452
                _textWriter?.Close();
                #endif
                _textWriter?.Dispose();
            }
        }

19 View Source File : MetricSnapshotInfluxDBLineProtocolWriter.cs
License : Apache License 2.0
Project Creator : AppMetrics

protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _points.Write(_textWriter);
#if !NETSTANDARD1_6
                _textWriter?.Close();
#endif
                _textWriter?.Dispose();
            }
        }

19 View Source File : XmlSettingsFormat.cs
License : MIT License
Project Creator : Aragas

public override bool Save(BaseSettings settings, string directoryPath, string filename)
        {
            var path = Path.Combine(directoryPath, filename + ".xml");

            var content = SaveJson(settings);
            var xmlDoreplacedent = JsonConvert.DeserializeXmlNode(content, settings is IWrapper wrapper1 ? wrapper1.Object.GetType().Name : settings.GetType().Name);

            var file = new FileInfo(path);
            file.Directory?.Create();
            var writer = file.CreateText();
            xmlDoreplacedent.Save(writer);
            writer.Dispose();

            return true;
        }

19 View Source File : BaseJsonSettingsFormat.cs
License : MIT License
Project Creator : Aragas

public virtual bool Save(BaseSettings settings, string directoryPath, string filename)
        {
            var path = Path.Combine(directoryPath, filename + ".json");

            var content = SaveJson(settings);

            var file = new FileInfo(path);
            file.Directory?.Create();
            var writer = file.CreateText();
            writer.Write(content);
            writer.Dispose();

            return true;
        }

19 View Source File : StructureLog.cs
License : MIT License
Project Creator : ark-mod

protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    _sw?.Dispose();
                    _sw = null;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }

19 View Source File : TraceLoggerPlus.cs
License : GNU General Public License v3.0
Project Creator : ASCOMInitiative

private void CreateLogFile()
        {
            // Initialise working copy of the log file path
            string logFilePath;

            int logFileSuffixInteger = 0; // Initialise suffix to 0

            // Establish the path to the log file, auto generating this if required
            try
            {
                if (autoGenerateFilePath) // We need to auto generate the file path
                {
                    if (!string.IsNullOrEmpty(Environment.GetFolderPath(Environment.SpecialFolder.Personal))) // This is a normaL "User" account
                    {
                        logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), AUTO_PATH_BASE_DIRECTORY, string.Format(AUTO_PATH_WINDOWS_DIRECTORY_TEMPLATE, DateTimeNow()));
                    }
                    else // This is the "System" account, which does not have a personal doreplacedents directory so put log files in the 
                    {
                        logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), AUTO_PATH_WINDOWS_SYSTEM_USER_BASE_DIRECTORY, string.Format(AUTO_PATH_WINDOWS_DIRECTORY_TEMPLATE, DateTimeNow()));
                    }
                }
                else // We need to use the supplied log file path, which is already in the logFilePath property
                {
                    logFilePath = Path.Combine(LogFilePath, string.Format(AUTO_PATH_WINDOWS_DIRECTORY_TEMPLATE, DateTimeNow()));
                }
            }
            catch (Exception ex)
            {
                throw new DriverException($"TraceLogger - Unable to find determine the log file path, IsWindows: {RuntimeInformation.IsOSPlatform(OSPlatform.Windows)}. {ex.Message}. See inner exception for details", ex);
            }

            // Create the directory if required
            try
            {
                Directory.CreateDirectory(logFilePath);
            }
            catch (Exception ex)
            {
                throw new DriverException($"TraceLogger - Unable to create log file directory '{logFilePath}': {ex.Message}. See inner exception for details", ex);
            }

            // Create the log file stream writer auto a file name if required
            if (autoGenerateFileName) // We need to auto-generate a file name ourselves
            {
                try
                {
                    // Create a unique log file name based on date, time and required name by incrementing an arbitrary final suffixed count value
                    do
                    {
                        LogFileName = string.Format(AUTO_FILE_NAME_TEMPLATE, logFileType, DateTimeNow(), logFileSuffixInteger);
                        checked { ++logFileSuffixInteger; } // Increment the counter to ensure that no log file can have the same name as any other
                    }
                    while (File.Exists(Path.Combine(logFilePath, LogFileName)) & (logFileSuffixInteger <= MAXIMUM_UNIQUE_SUFFIX_ATTEMPTS)); // Loop until the generated file name does not exist or we hit the maximum number of attempts

                    // Close any current file stream before creating a new one
                    if (!(logFileStream is null))
                    {
                        logFileStream.Close();
                        logFileStream.Dispose();
                    }

                    // Create the stream writer used to write to disk
                    logFileStream = new StreamWriter(Path.Combine(logFilePath, LogFileName), false);
                    logFileStream.AutoFlush = true;
                }
                catch (Exception ex)
                {
                    throw new DriverException($"TraceLogger - Unable to create auto-generated log file '{LogFileName}' in directory '{logFilePath}': {ex.Message}. See inner exception for details", ex);
                }
            }
            else // We need to use the supplied file name
            {
                try
                {
                    // Close any current file stream before creating a new one
                    if (!(logFileStream is null))
                    {
                        logFileStream.Close();
                        logFileStream.Dispose();
                    }

                    // Create the stream writer used to write to disk
                    logFileStream = new StreamWriter(Path.Combine(logFilePath, LogFileName), false);
                    logFileStream.AutoFlush = true;
                }
                catch (Exception ex)
                {
                    throw new DriverException($"TraceLogger - Unable to create log file '{LogFileName}' in directory '{logFilePath}': {ex.Message}. See inner exception for details", ex);
                }
            }
        }

19 View Source File : TraceLoggerPlus.cs
License : GNU General Public License v3.0
Project Creator : ASCOMInitiative

protected virtual void Dispose(bool disposing)
        {
            if (traceLoggerHasBeenDisposed) return;

            if (disposing)
            {
                if (logFileStream != null)
                {
                    try
                    {
                        logFileStream.Flush();
                    }
                    catch
                    {
                    }
                    try
                    {
                        logFileStream.Close();
                    }
                    catch
                    {
                    }
                    try
                    {
                        logFileStream.Dispose();
                    }
                    catch
                    {
                    }

                    logFileStream = null;
                }
                if (loggerMutex != null)
                {
                    try
                    {
                        loggerMutex.Close();
                    }
                    catch
                    {
                    }
                    loggerMutex = null;
                }

                traceLoggerHasBeenDisposed = true;
            }
        }

19 View Source File : BaseView.cs
License : Apache License 2.0
Project Creator : aspnet

public void Execute(IOwinContext context)
        {
            Context = context;
            Request = Context.Request;
            Response = Context.Response;
            Output = new StreamWriter(Response.Body);
            Execute();
            Output.Dispose();
        }

19 View Source File : DualWriter.cs
License : Apache License 2.0
Project Creator : aspnet

protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Writer2.Dispose();
            }
            base.Dispose(disposing);
        }

19 View Source File : ExceptionManager.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

public static void GenerateReport()
        {
            string gameInfo = GetGameInfo();

            int reportsInFolder = 0;
            while (File.Exists($"{LogFolder}/{DefaultReportLogName}_{reportsInFolder}.txt"))
                reportsInFolder++;

            string path = $"{LogFolder}/{DefaultReportLogName}_{reportsInFolder}.txt";

            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.Write(gameInfo);
                sw.Close();
                sw.Dispose();
            }

            ModConsole.Log("[MOP] Mod report has been successfully generated.");
            Process.Start(path);
        }

19 View Source File : Logging.cs
License : GNU General Public License v3.0
Project Creator : audiamus

private void closeWriter () {
      if (!(_logStreamWriter is null)) {
        _logStreamWriter.Dispose ();
      }
      _logStreamWriter = null;
    }

19 View Source File : TextLogger.cs
License : MIT License
Project Creator : AvaloniaCommunity

protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (Writer != null)
                {
                    Writer.Dispose();
                }
            }
        }

19 View Source File : TextLogger.cs
License : MIT License
Project Creator : AvaloniaCommunity

protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (writer != null)
                {
                    writer.Dispose();
                }
            }
        }

19 View Source File : TextLoggerFixture.cs
License : MIT License
Project Creator : AvaloniaCommunity

[TestMethod]
        public void ShouldDisposeWriterOnDispose()
        {
            MockWriter writer = new MockWriter();
            ILoggerFacade logger = new TextLogger() { Writer = writer };

            replacedert.IsFalse(writer.DisposeCalled);
            writer.Dispose();
            replacedert.IsTrue(writer.DisposeCalled);
        }

19 View Source File : IndentedTextWriter.cs
License : Apache License 2.0
Project Creator : aws

protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (_writer != null)
            {
                _writer.Dispose();
                _writer = null;
            }
        }

19 View Source File : Log.cs
License : MIT License
Project Creator : AyrA

public static void Close()
        {
            lock (Logger)
            {
                if (Logger != TextWriter.Null)
                {
                    var DT = DateTime.UtcNow;
                    Write("{0} {1}: Logger ended", DT.ToLongDateString(), DT.ToLongTimeString());
                    Logger.Flush();
                    Logger.Close();
                    Logger.Dispose();
                    Logger = TextWriter.Null;
                }
            }
        }

19 View Source File : MultiTextWriter.cs
License : The Unlicense
Project Creator : BAndysc

protected override void Dispose(bool disposing)
        {
            foreach (System.IO.TextWriter thisWriter in MWriters)
            {
                thisWriter.Dispose();
            }
        }

19 View Source File : BetterLogAppender.cs
License : GNU Lesser General Public License v2.1
Project Creator : BattletechModders

public void Dispose()
        {
            writer?.Dispose();
        }

19 View Source File : Appender.cs
License : The Unlicense
Project Creator : BattletechModders

public void Dispose()
        {
            lock(this)
            {
                writer?.Dispose();
            }
        }

19 View Source File : SaveGameJsonSerializer.cs
License : MIT License
Project Creator : BayatGames

public void Serialize<T> ( T obj, Stream stream, Encoding encoding )
		{
			#if !UNITY_WSA || !UNITY_WINRT
			try
			{
				StreamWriter writer = new StreamWriter ( stream, encoding );
				fsSerializer serializer = new fsSerializer ();
				fsData data = new fsData ();
				serializer.TrySerialize ( obj, out data );
				writer.Write ( fsJsonPrinter.CompressedJson ( data ) );
				writer.Dispose ();
			}
			catch ( Exception ex )
			{
				Debug.LogException ( ex );
			}
			#else
			StreamWriter writer = new StreamWriter ( stream, encoding );
			writer.Write ( JsonUtility.ToJson ( obj ) );
			writer.Dispose ();
			#endif
		}

19 View Source File : GeoLocationConverter.cs
License : Apache License 2.0
Project Creator : bcgov

public void Dispose()
        {
            _writer.Flush();
            _writer.Dispose();
        }

19 View Source File : ErrorLogger.cs
License : MIT License
Project Creator : bdfzchen2015

public void Dispose()
		{
			_logWriter.Dispose();
		}

19 View Source File : DiskLogListener.cs
License : GNU Lesser General Public License v2.1
Project Creator : BepInEx

public void Dispose()
        {
            FlushTimer?.Dispose();

            try
            {
                LogWriter?.Flush();
                LogWriter?.Dispose();
            }
            catch (ObjectDisposedException) { }
        }

19 View Source File : LuaBinary.cs
License : MIT License
Project Creator : Big-Endian-32

public void Dispose() 
                => _out.Dispose();

See More Examples