//public void WriteSizedBytes(byte[] data) //{ // Write((uint)data.Length); // base.Write(data); //} public override void Close() { base.Close(); OutStream.Close(); Dispose(true); OutStream.Dispose(); }
private void Dispose(bool disposing) { if (!disposed && disposing) { thrCancelTokens.Cancel(); try { listentingTask.Wait(settings.ReaderTimeout); } catch (AggregateException ex) { if (ex.InnerExceptions.Count != 1 || !(ex.InnerException is OperationCanceledException)) { throw; } } OutStream.Dispose(); InStream.Dispose(); bus.ForgetAll(); disposed = true; } }
public int Run() { if (!DynamicFields) { // read through and get the stats int n = GetFileStats(); if (n > 0) { return(n); } } try { OutStream = (WriteStdout ? Console.Out : new StreamWriter(FilenameOut)); if (UseTwoPassMethod || DynamicFields) { throw new Exception("TODO 2 pass"); } else { return(PrintOutFrame()); } } finally { if (OutStream != null && OutStream != Console.Out) { try { OutStream.Close(); } catch { } try { OutStream.Dispose(); } catch { } } } }
/// <summary> /// Clears this instance. /// </summary> public void Clear() { if (OutStream != null) { OutStream.Dispose(); } OutStream = new MemoryStream(); }
public void Dispose() { if (!IsDisposed) { FinishStream(); } IsDisposed = true; InStream?.Dispose(); OutStream?.Dispose(); ErrorStream?.Dispose(); }
/// <summary>This method copies the help files out of the program and into user-controlled temporary storage.</summary> private static void LoadHelp() { string[] AllHelpFiles = { HelpMain, HelpChar, HelpItems, HelpQuest, HelpSetts }; string[] AllHelpRes = { Resources.EQ2CollQuests, Resources.CharacterPage, Resources.ItemsPage, Resources.QuestsPage, Resources.SettingsPage }; FileStream OutStream; for (int counter = 0; counter < 5; counter++) { OutStream = File.Create(AllHelpFiles[counter]); OutStream.Write(Encoding.UTF8.GetBytes(AllHelpRes[counter]), 0, AllHelpRes[counter].Length); OutStream.Flush(); OutStream.Dispose(); } }
protected override void Dispose(bool disposing) { if (disposing) { if (_leaveOpen) { OutStream.Flush(); } else { OutStream.Dispose(); } } }
public static byte[] ObjectToBinary(Object obj, Boolean compress) { MemoryStream MemStream = null; DeflateStream DStream = null; MemoryStream OutStream = null; BinaryFormatter BinFormatter = default(BinaryFormatter); byte[] B = null; try { MemStream = new MemoryStream(); BinFormatter = new BinaryFormatter(); BinFormatter.Serialize(MemStream, obj); if (compress) { B = MemStream.ToArray(); OutStream = new MemoryStream(); DStream = new DeflateStream(OutStream, CompressionMode.Compress, false); DStream.Write(MemStream.ToArray(), 0, B.Length); DStream.Flush(); B = OutStream.ToArray(); } else { B = MemStream.ToArray(); } return(B); } finally { if ((OutStream != null)) { OutStream.Dispose(); } if ((DStream != null)) { DStream.Dispose(); } if ((MemStream != null)) { MemStream.Dispose(); } } }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects) InStream.Dispose(); OutStream.Dispose(); } // TODO: free unmanaged resources (unmanaged objects) and override finalizer // TODO: set large fields to null disposedValue = true; } }
public int Run() { TextReader instream = null; try { OutStream = (WriteStdout ? Console.Out : new StreamWriter(FilenameOut)); instream = (ReadStdin ? Console.In : new StreamReader(FilenameIn)); if (Verbose) { for (int i = 0; i < Fields.Count; ++i) { Field f = Fields[i]; OutStream.WriteLine(String.Format("Field{0}|{1}|{2}|", i, f.VerboseType, f.VerboseDefinition ) ); } } for (int row = 0; ; row++) { string line = instream.ReadLine(); if (line == null) { break; } string[] arr = ParseClass.ParseLine(line, TrimFields, Delimiter, PreserveQuotes, QuoteChar); PrintFields(arr); if (PrintTrailingDelim) { OutStream.Write(OutDelimiter); } OutStream.WriteLine(); } return(0); } finally { if (instream != null && instream != Console.In) { try { instream.Close(); } catch { } try { instream.Dispose(); } catch { } } if (OutStream != null && OutStream != Console.Out) { try { OutStream.Close(); } catch { } try { OutStream.Dispose(); } catch { } } } }
public void Dispose() { InStream.Dispose(); OutStream.Dispose(); }