Exemplo n.º 1
0
 public void Dispose()
 {
     _writer?.Flush();
     _writer?.Close();
     _writer?.Dispose();
     _writer = null;
 }
Exemplo n.º 2
0
        private void SaveFile()
        {
            if (ActualFilePath == string.Empty)
            {
                SaveFileAs();
                return;
            }
            Canvas.CanvObj.My_IsSelectedSetForAll(false);
            TextWriter writer = null;

            try
            {
                writer?.Close();
                var serializer = new XmlSerializer(typeof(int));
                writer = new StreamWriter(ActualFilePath, false);
                serializer.Serialize(writer, 0);

                writer.Close();
                ActualFilePath = ActualFilePath.Substring(0, ActualFilePath.Count() - 3) + "hab";
                serializer     = new XmlSerializer(typeof(ListCanvasBlocks));
                writer         = new StreamWriter(ActualFilePath, false);
                serializer.Serialize(writer, Canvas.CanvObj);

                writer.Close();
                ActualFilePath = ActualFilePath.Substring(0, ActualFilePath.Count() - 3) + "hal";
                serializer     = new XmlSerializer(typeof(ListCanvasLines));
                writer         = new StreamWriter(ActualFilePath, false);
                serializer.Serialize(writer, Canvas.CanvLines);
            }
            finally
            {
                writer?.Close();
            }
        }
Exemplo n.º 3
0
 public override void Close()
 {
     STDOUT?.Close();
     STDOUT = null;
     File?.Close();
     File = null;
 }
        private void SerializeOutput(IReadOnlyList <object> output, IFastJsonWriter writer)
        {
            TextWriter openStringWriter = null;

            void CloseStringWriter()
            {
                if (openStringWriter != null)
                {
                    openStringWriter.Close();
                    openStringWriter = null;
                }
            }

            foreach (var item in output)
            {
                switch (item)
                {
                case SimpleInspection inspection:
                    CloseStringWriter();
                    SerializeSimpleInspection(inspection, writer);
                    break;

                case MemoryInspection memory:
                    CloseStringWriter();
                    SerializeMemoryInspection(memory, writer);
                    break;

                case MemoryGraphInspection graph:
                    CloseStringWriter();
                    SerializeMemoryGraphInspection(graph, writer);
                    break;

                case string @string:
                    if (openStringWriter == null)
                    {
                        openStringWriter = writer.OpenString();
                    }
                    openStringWriter.Write(@string);
                    break;

                case char[] chars:
                    if (openStringWriter == null)
                    {
                        openStringWriter = writer.OpenString();
                    }
                    openStringWriter.Write(chars);
                    break;

                case null:
                    break;

                default:
                    CloseStringWriter();
                    writer.WriteValue("Unsupported output object type: " + item.GetType().Name);
                    break;
                }
            }
            openStringWriter?.Close();
        }
Exemplo n.º 5
0
        // Set with combination of enum flags -- setLogLevel(LogLevel.ConsoleInfo | LogLevel.ConsoleDebug)
        public static void SetLevel(LogLevel lvl)
        {
            writer?.Close();
            writer = LogFiles.Instance.CreateNew();

            level = lvl;
            Write("Log level set to " + level);
        }
Exemplo n.º 6
0
 public void Close()
 {
     if (!_isClosed)
     {
         _writer?.Flush();
         _writer?.Close();
         _isClosed = true;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources.
 /// </summary>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _points.Write(_textWriter);
         _textWriter?.Close();
         _textWriter?.Dispose();
     }
 }
Exemplo n.º 8
0
 /// <summary>
 ///     Releases unmanaged and - optionally - managed resources.
 /// </summary>
 /// <param name="disposing">
 ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only
 ///     unmanaged resources.
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         #if NET452
         _textWriter?.Close();
         #endif
         _textWriter?.Dispose();
     }
 }
Exemplo n.º 9
0
        public void Dispose()
        {
            newWriter?.Close();
            modWriter?.Close();
            delWriter?.Close();
            sameWriter?.Close();

            newDirWriter?.Close();
            delDirWriter?.Close();
        }
Exemplo n.º 10
0
        public static void Generate(DbInfo dbInfo, bool includeData, bool seperateSchemaAndData, string outputDir)
        {
            Directory.CreateDirectory(outputDir);
            string     schemaFileName = null, dataFileName = null;
            TextWriter twForSchema = null, twForData = null;

            try
            {
                if (seperateSchemaAndData)
                {
                    schemaFileName = Path.Combine(outputDir, $"{dbInfo.DbName}-schema.sql");
                    twForSchema    = File.CreateText(schemaFileName);
                    dataFileName   = Path.Combine(outputDir, $"{dbInfo.DbName}-data.sql");
                    twForData      = File.CreateText(dataFileName);
                }
                else
                {
                    schemaFileName = dataFileName = Path.Combine(outputDir, $"{dbInfo.DbName}.sql");
                    twForSchema    = twForData = File.CreateText(schemaFileName);
                }

                IScriptService scriptService = new SmoService();

                scriptService.GenerateSchema(dbInfo, twForSchema);
                twForSchema.Flush();

                if (includeData)
                {
                    scriptService.GenerateData(dbInfo, twForData);
                    twForData.Flush();
                }
            }
            catch (Exception e)
            {
                // clean up
                try
                {
                    twForSchema?.Close();
                    twForData?.Close();
                    File.Delete(schemaFileName);
                    File.Delete(dataFileName);
                }
                catch
                {
                }

                throw e;
            }
            finally
            {
                twForSchema?.Dispose();
                twForData?.Dispose();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing">
        ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only
        ///     unmanaged resources.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _points.Write(_textWriter);
#if !NETSTANDARD1_6
                _textWriter?.Close();
#endif
                _textWriter?.Dispose();
            }
        }
 public void Error(String ErrorMessage, bool writeinFile)
 {
     if (writeinFile == true)/*Write in a file located at C:\Users\Public\Documents\VisualBlock*/{
         TextWriter errorInFile = new TextWriter();
         errorInFile.Write(ErrorMessage, @"C:\Users\Public\Documents\VisualBlock\Error.txt");
         errorInFile.Close();
     }
     else{
         MessageBox.Show(ErrorMessage, "Error");
     }
 }
Exemplo n.º 13
0
        public void Dispose()
        {
            _textWriter?.Close();
            _textWriter?.Dispose();

            // TODO pulled this in because we originally had it in the indel file writer because it was apparently causing problems. Test if the same problem still exists, otherwise this is overkill.
            if (_linesWritten == 0)
            {
                File.CreateText(_path).Close();
            }
        }
Exemplo n.º 14
0
        // NOTE: This function may only be called while the write lock is held
        private Task SwitchFiles(string suffix)
        {
            string filename = _baselineFilename + suffix;

            // close the old file
            _currentFileWriter?.Close();
            // open a new one
            _currentFileWriter = new StreamWriter(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite));
            // this really SHOULD be async--why can't windows open files asynchronously still!
            return(Task.CompletedTask);
        }
Exemplo n.º 15
0
        private void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            writer?.Close();
            writer?.Dispose();
            writer = null;
        }
Exemplo n.º 16
0
        public void Dispose()
        {
            Flush();
            textWriter?.Flush();

            if (!closeStream)
            {
                return;
            }
            textWriter?.Close();
            textWriter?.Dispose();
        }
Exemplo n.º 17
0
        private void SerializeOutput(IReadOnlyList <object> output, IFastJsonWriter writer)
        {
            TextWriter openStringWriter = null;

            foreach (var item in output)
            {
                switch (item)
                {
                case InspectionResult inspection:
                    if (openStringWriter != null)
                    {
                        openStringWriter.Close();
                        openStringWriter = null;
                    }
                    writer.WriteStartObject();
                    writer.WriteProperty("type", "inspection");
                    writer.WriteProperty("title", inspection.Title);
                    writer.WriteProperty("value", inspection.Value);
                    writer.WriteEndObject();
                    break;

                case string @string:
                    if (openStringWriter == null)
                    {
                        openStringWriter = openStringWriter ?? writer.OpenString();
                    }
                    openStringWriter.Write(@string);
                    break;

                case char[] chars:
                    if (openStringWriter == null)
                    {
                        openStringWriter = writer.OpenString();
                    }
                    openStringWriter.Write(chars);
                    break;

                case null:
                    break;

                default:
                    if (openStringWriter != null)
                    {
                        openStringWriter.Close();
                        openStringWriter = null;
                    }
                    writer.WriteValue("Unsupported output object type: " + item.GetType().Name);
                    break;
                }
            }
            openStringWriter?.Close();
        }
Exemplo n.º 18
0
        private bool disposedValue; // To detect redundant calls

        private void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _startSendEvent.Dispose();
                    CrashLogWriter?.Close();
                }

                disposedValue = true;
            }
        }
Exemplo n.º 19
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposedValue)
     {
         if (disposing)
         {
             _writer?.Flush();
             _writer?.Close();
             _writer?.Dispose();
         }
         _disposedValue = true;
     }
 }
Exemplo n.º 20
0
        private void CloseBufferAndWriter()
        {
            if (_writeBuffer != null)
            {
                BufferUtils.ReturnBuffer(_arrayPool, _writeBuffer);
                _writeBuffer = null;
            }

            if (CloseOutput)
            {
                _writer?.Close();
            }
        }
Exemplo n.º 21
0
 public void Dispose()
 {
     try
     {
         _stream?.Flush();
         _stream?.Close();
         _stream?.Dispose();
     }
     catch (Exception)
     {
         // ignore
     }
 }
Exemplo n.º 22
0
 private void FillTest()
 {
     //Discarded unreachable code: IL_0002
     //IL_0003: Incompatible stack heights: 0 vs 1
     if (m_RegistryComposer != null)
     {
         ValueFilterResolver.RestartIssuer(_AttrComposer, m_RegistryComposer);
         m_RegistryComposer = null;
     }
     if (base._0001())
     {
         m_MethodComposer?.Close();
     }
 }
Exemplo n.º 23
0
        private void CloseBufferAndWriter()
        {
            if (_writeBuffer != null)
            {
                BufferUtils.ReturnBuffer(_arrayPool, _writeBuffer);
                _writeBuffer = null;
            }

            if (CloseOutput)
            {
#if !(DOTNET || PORTABLE40 || PORTABLE)
                _writer?.Close();
#else
                _writer?.Dispose();
#endif
            }
        }
Exemplo n.º 24
0
        private void CloseBufferAndWriter()
        {
            if (_writeBuffer != null)
            {
                BufferUtils.ReturnBuffer(_arrayPool, _writeBuffer);
                _writeBuffer = null;
            }

            if (CloseOutput)
            {
#if HAVE_STREAM_READER_WRITER_CLOSE
                _writer?.Close();
#else
                _writer?.Dispose();
#endif
            }
        }
Exemplo n.º 25
0
 public static void CloseFileStreamers(params object[] streams)
 {
     foreach (object item in streams)
     {
         Stream     s  = null;
         TextWriter sw = null;
         TextReader sr = null;
         if ((s = item as Stream) is Stream ||
             (sw = item as TextWriter) is TextWriter ||
             (sr = item as TextReader) is TextReader)
         {
             s?.Close();
             sw?.Close();
             sr?.Close();
         }
     }
 }
Exemplo n.º 26
0
        /// <summary>
        /// 创建日志
        /// </summary>
        private void CreateLog()
        {
            try
            {
                mDate = DateTime.Now;

                FileStream fs = new FileStream(LogPath + mDate.ToString("yyyyMMdd") + (string.IsNullOrEmpty(GuidPath) ? "" : "-" + GuidPath) + ".log", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
                fs.Seek(0, SeekOrigin.End);

                //先关闭旧有日志
                mLogWriter?.Close();

                mLogWriter = new StreamWriter(fs);
                mLogWriter.WriteLine("\r\n====================================================================================================================\r\n");
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.ToString());
            }
        }
    public void Run(string [] args)
    {
        fs1 = File.CreateText ("type-hierarchy.xml");
        fs1.WriteLine ("<android-hierarchy xmlns:android='" + android_ns + "'>");

        foreach (var arg in new string [] {"http://developer.android.com/reference/android/view/View.html"}) {
            var baseUrl = resolver.ResolveUri (null, arg);
            var doc = FetchXmlDocument (baseUrl);

            ProcessDocument (baseUrl);

            foreach (XmlElement node in doc.SelectNodes ("//div[@id='subclasses-direct' or @id='subclasses-indirect']")) {
                foreach (XmlElement link in node.SelectNodes ("div/table[@class='jd-sumtable-expando']/tr/td[@class='jd-linkcol']/a[@href]")) {
                    if (link.PreviousSibling != null && link.PreviousSibling.Value.Contains ("extends"))
                        continue; // it is a link to generic type argument.
                    var durl = resolver.ResolveUri (baseUrl, link.GetAttribute ("href"));
                    ProcessDocument (durl);
                }
            }
        }
        fs1.WriteLine ("</android-hierarchy>");
        fs1.Close ();
    }
Exemplo n.º 28
0
        private void SaveFileAs()
        {
            SaveFileDialog savefile = new SaveFileDialog();

            savefile.FileName = ".xml";
            savefile.Filter   = "XML (*.xml)|*.xml";
            Canvas.CanvObj.My_IsSelectedSetForAll(false);
            if (savefile.ShowDialog() == DialogResult.OK)
            {
                ActualFilePath = savefile.FileName;
                TextWriter writer = null;
                try
                {
                    writer?.Close();
                    var serializer = new XmlSerializer(typeof(int));
                    writer = new StreamWriter(savefile.FileName, false);
                    serializer.Serialize(writer, 0);

                    writer?.Close();
                    savefile.FileName = savefile.FileName.Substring(0, savefile.FileName.Count() - 3) + "hab";
                    serializer        = new XmlSerializer(typeof(ListCanvasBlocks));
                    writer            = new StreamWriter(savefile.FileName, false);
                    serializer.Serialize(writer, Canvas.CanvObj);


                    writer?.Close();
                    savefile.FileName = savefile.FileName.Substring(0, savefile.FileName.Count() - 3) + "hal";
                    serializer        = new XmlSerializer(typeof(ListCanvasLines));
                    writer            = new StreamWriter(savefile.FileName, false);
                    serializer.Serialize(writer, Canvas.CanvLines);
                }
                finally
                {
                    writer?.Close();
                }
            }
        }
Exemplo n.º 29
0
 public override void Close()
 {
     STDOUT?.Close();
     File?.Close();
 }
Exemplo n.º 30
0
 public void Close()
 {
     TextWriter?.Flush();
     TextWriter?.Close();
     TextWriter = null;
 }
Exemplo n.º 31
0
 public override void OnShutdown() => logWriter?.Close();
Exemplo n.º 32
0
 public void Dispose()
 {
     _writer?.Close();
     _writer?.Dispose();
 }
Exemplo n.º 33
0
    void EndOfItems()
    {
        back.Hide ();
        ok.Hide ();
        notes.Hide ();
        launch.Hide ();

        quit.Show ();

        checklist.Current().complete = true;

        currentItem.Text = "Checklist Complete";

        Directory.CreateDirectory ("checklist_logs");

        String fname = DateTime.Now.ToString ("yyyy-MM-dd HH-mm") + " checklist.txt";
        String path = System.IO.Path.Combine ("checklist_logs", fname);

        log = new StreamWriter (path);
        log.Write (checklist.ToString ());
        log.Close ();
    }