public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { WkbWriterSettings target = new WkbWriterSettings(); target.IsReadOnly = true; Assert.Throws<InvalidOperationException>(() => target.Encoding = BinaryEncoding.BigEndian); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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()); } } }
/// <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; }
/// <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; }
/// <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); }