public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly()
        {
            WkbWriterSettings target = new WkbWriterSettings();
            target.IsReadOnly = true;

            Assert.Throws<InvalidOperationException>(() => target.Encoding = BinaryEncoding.BigEndian);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the WkbWriter class that writes geometries to a stream with specific settings.
        /// </summary>
        /// <param name="stream">The stream to write geometries to.</param>
        /// <param name="settings">The settings defining behaviour of the writer.</param>
        public WkbWriter(Stream stream, WkbWriterSettings settings)
            : this(settings) {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            _writer = new BinaryWriter(stream);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the WkbWriter class that writes geometries to a stream with specific settings.
        /// </summary>
        /// <param name="stream">The stream to write geometries to.</param>
        /// <param name="settings">The settings defining behaviour of the writer.</param>
        public WkbWriter(Stream stream, WkbWriterSettings settings)
            : this(settings)
        {
            if (stream == null) {
                throw new ArgumentNullException("stream");
            }

            _writer = new BinaryWriter(stream);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the WkbWriter class that writes geometreis to a file with specific settings.
        /// </summary>
        /// <param name="path">The path to the file to write geometrie to.</param>
        /// <param name="settings">The settings defining behaviour of the writer.</param>
        public WkbWriter(string path, WkbWriterSettings settings)
            : this(settings) {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            _output = new FileStream(path, FileMode.Create, FileAccess.Write);
            _writer = new BinaryWriter(_output);
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the WkbWriter class that writes geometreis to a file with specific settings.
        /// </summary>
        /// <param name="path">The path to the file to write geometrie to.</param>
        /// <param name="settings">The settings defining behaviour of the writer.</param>
        public WkbWriter(string path, WkbWriterSettings settings)
            : this(settings)
        {
            if (path == null) {
                throw new ArgumentNullException("path");
            }

            _output = new FileStream(path, FileMode.Create, FileAccess.Write);
            _writer = new BinaryWriter(_output);
        }
Example #6
0
        /// <summary>
        /// Writes specified Geometry in the WKB format to a binary arrray using default WkbWriterSettings.
        /// </summary>
        /// <param name="geometry">The geometry to write.</param>
        /// <returns>The binary array with WKB representation of the Geometry.</returns>
        public static byte[] WriteToArray(IGeometry geometry)
        {
            using (MemoryStream dataStream = new MemoryStream()) {
                using (BinaryWriter writer = new BinaryWriter(dataStream)) {
                    WkbWriterSettings defaultSettings = new WkbWriterSettings();

                    WkbWriter.WriteEncoding(writer, defaultSettings.Encoding);
                    WkbWriter.Write(geometry, writer);

                    return(dataStream.ToArray());
                }
            }
        }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the WkbWriter class with specific settings.
        /// </summary>
        /// <param name="settings">The settings defining behaviour of the writer.</param>
        protected WkbWriter(WkbWriterSettings settings)
        {
            if (settings == null) {
                throw new ArgumentNullException("settings");
            }

            if (settings.Encoding == BinaryEncoding.BigEndian) {
                throw new NotSupportedException("BigEndian encoding is not supported in current version of the WkbWriter.");
            }

            this.Settings = settings;
            this.Settings.IsReadOnly = true;
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the WkbWriter class with specific settings.
        /// </summary>
        /// <param name="settings">The settings defining behaviour of the writer.</param>
        protected WkbWriter(WkbWriterSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (settings.Encoding == BinaryEncoding.BigEndian)
            {
                throw new NotSupportedException("BigEndian encoding is not supported in current version of the WkbWriter.");
            }

            this.Settings            = settings;
            this.Settings.IsReadOnly = true;
        }
Example #9
0
        /// <summary>
        /// Writes specified Geometry in the WKB format to a binary arrray using default WkbWriterSettings.
        /// </summary>
        /// <param name="geometry">The geometry to write.</param>
        /// <returns>The binary array with WKB representation of the Geometry.</returns>
        public static byte[] WriteToArray(IGeometry geometry)
        {
            using (MemoryStream dataStream = new MemoryStream()) {
                using (BinaryWriter writer = new BinaryWriter(dataStream)) {
                    WkbWriterSettings defaultSettings = new WkbWriterSettings();

                    WkbWriter.WriteEncoding(writer, defaultSettings.Encoding);
                    WkbWriter.Write(geometry, writer);

                    return dataStream.ToArray();
                }
            }
        }
        public void Constructor__SetsDefaultValues()
        {
            WkbWriterSettings target = new WkbWriterSettings();

            Assert.Equal(BinaryEncoding.LittleEndian, target.Encoding);
        }