Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the BsonWriter class.
 /// </summary>
 protected BsonWriter(
     BsonWriterSettings settings
     )
 {
     this.settings = settings.Freeze();
     this.state    = BsonWriterState.Initial;
 }
Esempio n. 2
0
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public virtual void WriteName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.IndexOf('\0') != -1)
            {
                throw new BsonSerializationException("Element names cannot contain nulls.");
            }
            if (_disposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (_state != BsonWriterState.Name)
            {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }

            if (!_elementNameValidator.IsValidElementName(name))
            {
                var message = string.Format("Element name '{0}' is not valid'.", name);
                throw new BsonSerializationException(message);
            }
            _childElementNameValidatorFactory = () => _elementNameValidator.GetValidatorForChildContent(name);

            _name  = name;
            _state = BsonWriterState.Value;
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the BsonWriter class.
 /// </summary>
 /// <param name="settings">The writer settings.</param>
 protected BsonWriter(
     BsonWriterSettings settings
 )
 {
     this.settings = settings.FrozenCopy();
     this.state = BsonWriterState.Initial;
 }
        // constructors
        /// <summary>
        /// Initializes a new instance of the BsonWriter class.
        /// </summary>
        /// <param name="settings">The writer settings.</param>
        protected BsonWriter(BsonWriterSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            _settings = settings.FrozenCopy();
            _state = BsonWriterState.Initial;
        }
Esempio n. 5
0
        // constructors
        /// <summary>
        /// Initializes a new instance of the BsonWriter class.
        /// </summary>
        /// <param name="settings">The writer settings.</param>
        protected BsonWriter(BsonWriterSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            _settings = settings.FrozenCopy();
            _state    = BsonWriterState.Initial;
        }
Esempio n. 6
0
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public virtual void WriteName(string name)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (state != BsonWriterState.Name)
            {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }
            CheckElementName(name);

            this.name = name;
            state     = BsonWriterState.Value;
        }
Esempio n. 7
0
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public override void WriteName(
            string name
            )
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (state != BsonWriterState.Name)
            {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }

            this.name = name;
            state     = BsonWriterState.Value;
        }
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public override void WriteName(
            string name
            )
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (state != BsonWriterState.Name)
            {
                var message = string.Format("WriteName cannot be called when State is: {0}", state);
                throw new InvalidOperationException(message);
            }

            this.name = name;
            state     = BsonWriterState.Value;
        }
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public virtual void WriteName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.IndexOf('\0') != -1)
            {
                throw new ArgumentException("Element names cannot contain nulls.", "name");
            }
            if (_disposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (_state != BsonWriterState.Name)
            {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }
            CheckElementName(name);

            _name  = name;
            _state = BsonWriterState.Value;
        }
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public virtual void WriteName(string name)
        {
            if (_disposed) { throw new ObjectDisposedException(this.GetType().Name); }
            if (_state != BsonWriterState.Name)
            {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }
            CheckElementName(name);

            _name = name;
            _state = BsonWriterState.Value;
        }
Esempio n. 11
0
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public virtual void WriteName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.IndexOf('\0') != -1)
            {
                throw new BsonSerializationException("Element names cannot contain nulls.");
            }
            if (_disposed) { throw new ObjectDisposedException(this.GetType().Name); }
            if (_state != BsonWriterState.Name)
            {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }

            if (!_elementNameValidator.IsValidElementName(name))
            {
                var message = string.Format("Element name '{0}' is not valid'.", name);
                throw new BsonSerializationException(message);
            }
            _childElementNameValidatorFactory = () => _elementNameValidator.GetValidatorForChildContent(name);

            _name = name;
            _state = BsonWriterState.Value;
        }
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public override void WriteName(
            string name
        ) {
            if (disposed) { throw new ObjectDisposedException(this.GetType().Name); }
            if (state != BsonWriterState.Name) {
                var message = string.Format("WriteName cannot be called when State is: {0}", state);
                throw new InvalidOperationException(message);
            }

            this.name = name;
            state = BsonWriterState.Value;
        }
Esempio n. 13
0
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public virtual void WriteName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.IndexOf('\0') != -1)
            {
                throw new BsonSerializationException("Element names cannot contain nulls.");
            }
            if (_disposed) { throw new ObjectDisposedException(this.GetType().Name); }
            if (_state != BsonWriterState.Name)
            {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }
            CheckElementName(name);

            _name = name;
            _state = BsonWriterState.Value;
        }
Esempio n. 14
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the BsonWriter class.
 /// </summary>
 /// <param name="settings">The writer settings.</param>
 protected BsonWriter(BsonWriterSettings settings)
 {
     _settings = settings.FrozenCopy();
     _state    = BsonWriterState.Initial;
 }
Esempio n. 15
0
        /// <summary>
        /// Writes the name of an element to the writer.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        public override void WriteName(
            string name
        ) {
            if (disposed) { throw new ObjectDisposedException(this.GetType().Name); }
            if (state != BsonWriterState.Name) {
                ThrowInvalidState("WriteName", BsonWriterState.Name);
            }

            this.name = name;
            state = BsonWriterState.Value;
        }