コード例 #1
0
        private void LoadFromFileName(string filename)
        {
            _fileName = filename;

            StreamReader reader = null;

            try {
                if (PreserveWhitespace)
                {
                    _preservationProvider = new XmlAttributePreservationProvider(filename);
                }

                const int defaultFileStreamBufferSize = 1024;
                var       stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read,
                                                  defaultFileStreamBufferSize, FileOptions.SequentialScan);

                reader = new StreamReader(stream, Encoding.UTF8, true);
                LoadFromTextReader(reader);
            }
            finally {
                if (_preservationProvider != null)
                {
                    _preservationProvider.Close();
                    _preservationProvider = null;
                }
                if (reader != null)
                {
                    reader.Dispose();
                }
            }
        }
コード例 #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (_reader != null)
            {
                _reader.Dispose();
                _reader = null;
            }

            if (_preservationProvider != null)
            {
                _preservationProvider.Close();
                _preservationProvider = null;
            }
        }