示例#1
0
        /// <summary>
        /// Updates the file with all changes the write buffer contains.
        /// </summary>
        public void ApplyChanges()
        {
            if (this._readOnly)
            {
                throw new Exception("FileWorker_ReadCompleted is in read-only mode.");
            }

            if (!HasChanges())
            {
                return;
            }

            IDictionaryEnumerator en = _writes.GetEnumerator();

            while (en.MoveNext())
            {
                long index = (long)en.Key;
                byte value = (byte)en.Value;
                if (_fileStream.Position != index)
                {
                    _fileStream.Position = index;
                }
                _fileStream.Write(new byte[] { value }, 0, 1);
            }
            _writes.Clear();
        }
示例#2
0
        public void Collections_Clear()
        {
            var item1 = CreateItem1();
            var item2 = CreateItem2();

            WriteCollection.Add(item1);
            WriteCollection.Add(item2);

            WriteCollection.Clear();

            ReadCollection.AssertEmpty();
        }
示例#3
0
        /// <summary>
        /// Updates the file with all changes the write buffer contains.
        /// </summary>
        public void ApplyChanges()
        {
            if (!HasChanges())
            {
                return;
            }

            IDictionaryEnumerator en = _writes.GetEnumerator();

            while (en.MoveNext())
            {
                long index = (long)en.Key;
                byte value = (byte)en.Value;
                if (_fileStream.Position != index)
                {
                    _fileStream.Position = index;
                }
                _fileStream.Write(new byte[] { value }, 0, 1);
            }
            _writes.Clear();
        }
示例#4
0
            /// <summary>
            /// Updates the file with all changes the write buffer contains.
            /// </summary>
            public void ApplyChanges()
            {
                if (!HasChanges)
                {
                    return;
                }

                var enumerator = bytes.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    long index = (long)enumerator.Key;
                    byte value = (byte)enumerator.Value;
                    if (fileStream.Position != index)
                    {
                        fileStream.Position = index;
                    }
                    fileStream.Write(new byte[] { value }, 0, 1);
                }
                bytes.Clear();
            }
        /// <summary>
        ///   Updates the file with all changes the write buffer contains.
        /// </summary>
        public void ApplyChanges()
        {
            if (_readOnly)
            {
                throw new FieldAccessException("File is in read-only mode.");
            }
            if (!HasChanges())
            {
                return;
            }
            var en = _writes.GetEnumerator();

            while (en.MoveNext())
            {
                var index = (long)en.Key;
                var value = (byte)en.Value;
                _fileStream.Position = index;
                _fileStream.Write(new[] { value }, 0, 1);
            }
            _writes.Clear();
        }
示例#6
0
        /// <summary>
        ///   Updates the file with all changes the write buffer contains.
        /// </summary>
        public void ApplyChanges()
        {
            if (!HasChanges())
            {
                return;
            }

            var en = _writes.GetEnumerator();

            while (en.MoveNext())
            {
                var index = (long)en.Key;
                var value = (byte)en.Value;
                _fileStream.Position = index;
                _fileStream.Write(new[]
                {
                    value
                }, 0, 1);
            }
            _writes.Clear();
        }