/// <summary> /// Creates a write-only DimeRecord object. /// </summary> /// <param name="stream">stream must be open and writeable.</param> /// <param name="id">id must be null or a valid URI.</param> /// <param name="type">type must be a valid URI or a media type.</param> /// <param name="contentLength">contentLength is the length of the records content. If contentLength /// equals -1, chunking is used.</param> /// <param name="beginOfMessage">beginOfMessage marks this record as the first record in a message.</param> internal DimeRecord(Stream stream, Uri id, String type, TypeFormatEnum typeFormat, bool beginOfMessage, int contentLength, int chunkSize) { if (stream == null) { throw new ArgumentNullException("stream"); } if (type == null) { throw new ArgumentNullException("type"); } if (!stream.CanWrite) { throw new ArgumentException("Stream CanWrite property must be true.", "stream"); } if (contentLength < -1) { throw new ArgumentException("contentLength must be -1 for chunked or a non-negative number", "contentLength"); } SetType(type, typeFormat); m_id = id; m_contentLength = contentLength; m_chunked = contentLength == -1; m_firstChunk = m_chunked; m_beginOfMessage = beginOfMessage; m_stream = stream; m_ioMode = IOModeEnum.WriteOnly; m_chunkSize = chunkSize; }
public static StringIO /*!*/ Create(RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ initialString, [DefaultProtocol, Optional, NotNull] MutableString mode) { IOMode ioMode = IOModeEnum.Parse(mode, initialString.IsFrozen ? IOMode.ReadOnly : IOMode.ReadWrite) | IOMode.PreserveEndOfLines; return(new StringIO(CheckContent(initialString, ioMode), ioMode)); }
internal DimeRecord(Stream stream, Uri id, string type, TypeFormatEnum typeFormat, bool beginOfMessage, int contentLength, int chunkSize) { if (stream == null) { throw new ArgumentNullException("stream"); } if (type == null) { throw new ArgumentNullException("type"); } if (!stream.CanWrite) { throw new ArgumentException(XmlaSR.DimeRecord_StreamShouldBeWriteable, "stream"); } if (contentLength < -1) { throw new ArgumentException(XmlaSR.DimeRecord_InvalidContentLength, "contentLength"); } this.SetType(type, typeFormat); this.m_id = id; this.m_contentLength = contentLength; this.m_chunked = (contentLength == -1); this.m_firstChunk = this.m_chunked; this.m_beginOfMessage = beginOfMessage; this.m_stream = stream; this.m_ioMode = IOModeEnum.WriteOnly; this.m_chunkSize = chunkSize; }
public static StringIO /*!*/ Reopen(StringIO /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ content, [DefaultProtocol, NotNull] MutableString mode) { IOMode ioMode = IOModeEnum.Parse(mode, content.IsFrozen ? IOMode.ReadOnly : IOMode.ReadWrite) | IOMode.PreserveEndOfLines; self.SetContent(CheckContent(content, ioMode)); self._mode = ioMode; return(self); }
/// <summary> /// Creates a read-only DimeRecord object. /// </summary> /// <param name="stream">Must be an open and readable stream.</param> internal DimeRecord (Stream stream) { if (stream == null) throw new ArgumentNullException("stream"); if (!stream.CanRead) throw new ArgumentException("Stream CanRead property must be true.", "stream"); m_ioMode = IOModeEnum.ReadOnly; m_stream = stream; // Note, a blocking I/O call in the constructor. Consider delaying this to do it on-demand so // we can provide async semantics. ReadHeader(); }
internal DimeRecord(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException(XmlaSR.DimeRecord_StreamShouldBeReadable, "stream"); } this.m_ioMode = IOModeEnum.ReadOnly; this.m_stream = stream; this.m_firstChunk = true; this.ReadHeader(); }
/// <summary> /// Creates a read-only DimeRecord object. /// </summary> /// <param name="stream">Must be an open and readable stream.</param> internal DimeRecord(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException("Stream CanRead property must be true.", "stream"); } m_ioMode = IOModeEnum.ReadOnly; m_stream = stream; // Note, a blocking I/O call in the constructor. Consider delaying this to do it on-demand so // we can provide async semantics. ReadHeader(); }
/// <summary> /// Creates a write-only DimeRecord object. /// </summary> /// <param name="stream">stream must be open and writeable.</param> /// <param name="id">id must be null or a valid URI.</param> /// <param name="type">type must be a valid URI or a media type.</param> /// <param name="contentLength">contentLength is the length of the records content. If contentLength /// equals -1, chunking is used.</param> /// <param name="beginOfMessage">beginOfMessage marks this record as the first record in a message.</param> internal DimeRecord (Stream stream, Uri id, String type, TypeFormatEnum typeFormat, bool beginOfMessage, int contentLength, int chunkSize) { if (stream == null) throw new ArgumentNullException("stream"); if (type == null) throw new ArgumentNullException("type"); if (!stream.CanWrite) throw new ArgumentException("Stream CanWrite property must be true.", "stream"); if (contentLength < -1) throw new ArgumentException("contentLength must be -1 for chunked or a non-negative number", "contentLength"); SetType(type, typeFormat); m_id = id; m_contentLength = contentLength; m_chunked = contentLength == -1; m_firstChunk = m_chunked; m_beginOfMessage = beginOfMessage; m_stream = stream; m_ioMode = IOModeEnum.WriteOnly; m_chunkSize = chunkSize; }