本文整理汇总了C#中SeekOrigin类的典型用法代码示例。如果您正苦于以下问题:C# SeekOrigin类的具体用法?C# SeekOrigin怎么用?C# SeekOrigin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SeekOrigin类属于命名空间,在下文中一共展示了SeekOrigin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Seek
public override long Seek(long offset, SeekOrigin origin)
{
var len = Length;
switch (origin)
{
case SeekOrigin.Begin:
_position = offset;
break;
case SeekOrigin.Current:
_position += offset;
break;
case SeekOrigin.End:
_position = len - offset;
break;
}
if (_position > len)
{
_position = len;
}
else if (_position < 0)
{
_position = 0;
}
return _position;
}
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:25,代码来源:MultiStream.cs
示例2: Seek
public override Int64 Seek(Int64 offset, SeekOrigin origin) {
Contract.Requires((int)origin >= 0);
Contract.Requires((int)origin <= 2);
Contract.EnsuresOnThrow<System.IO.IOException>(true, @"An I/O error occurred.");
return default(Int64);
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:System.IO.FileStream.cs
示例3: Seek
public void Seek(long offset, SeekOrigin origin)
{
int totalCount;
if (this._typeIsDocument)
totalCount = this._db.Statistics.CountOfDocuments;
else
totalCount = this._db.Statistics.CountOfIndexes;
if (offset > totalCount)
{
throw new
ArgumentException(
"Offset cannot be greater than the number of " + (_typeIsDocument ? "documents" : "indexes")
);
}
if (origin == SeekOrigin.Begin)
{
// starting from Beginning with an index 0, the current offset
// has to be advanced to offset - 1
_currentOffset = _currentOffset - 1;
}
else if (origin == SeekOrigin.End)
{
// starting from the end which is numRows - 1, the current
// offset is so much less than numRows - 1
_currentOffset = totalCount - 1 - _currentOffset;
}
else
{
// calculate from the previous value of current offset
// advancing forward always
_currentOffset += Convert.ToInt32(offset);
}
}
开发者ID:kenegozi,项目名称:ravendb,代码行数:35,代码来源:RavenDBContentReader.cs
示例4: Seek
public override long Seek(long offset, SeekOrigin origin)
{
lock (underlyingStream)
{
return underlyingStream.Seek(offset, origin);
}
}
开发者ID:gemcfadyen,项目名称:task-list,代码行数:7,代码来源:BlockingStream.cs
示例5: Seek
/// <summary>
/// Sets the position within the current stream.
/// </summary>
/// <param name="offset">A byte offset relative to the <paramref name="origin"/> parameter.</param>
/// <param name="origin">A value of type <see cref="T:System.IO.SeekOrigin"/> indicating the reference point used to obtain the new position.</param>
/// <returns>The new position within the current stream.</returns>
public override long Seek(long offset, SeekOrigin origin)
{
if (origin == SeekOrigin.Begin)
offset += m_baseOffset;
return base.Seek(offset, origin) - m_baseOffset;
}
开发者ID:mattrudder,项目名称:mono-embed,代码行数:13,代码来源:RebasedStream.cs
示例6: Seek
/// <summary>
/// Seek
/// </summary>
/// <param name="offset">offset</param>
/// <param name="origin">origin</param>
/// <returns>zero</returns>
public override long Seek(long offset, SeekOrigin origin)
{
ReadAttempt();
long temp = -1;
switch (origin)
{
// seek beyond the FormatVersion
case SeekOrigin.Begin:
temp = offset;
break;
case SeekOrigin.Current:
checked { temp = Position + offset; }
break;
case SeekOrigin.End:
checked { temp = Length + offset; }
break;
}
if (temp < 0)
throw new ArgumentException(SR.Get(SRID.SeekNegative));
checked { BaseStream.Position = temp + _dataOffset; }
return temp;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:33,代码来源:VersionedStreamOwner.cs
示例7: Seek
public override long Seek(
long offset,
SeekOrigin origin
)
{
return _baseStream.Seek(offset, origin);
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:7,代码来源:ZipWrappingStream.cs
示例8: Seek
public override long Seek(long offset, SeekOrigin origin)
{
switch (origin)
{
case SeekOrigin.Begin:
{
if (offset != Position)
return base.Seek(offset, origin);
}
break;
case SeekOrigin.Current:
{
if (offset != 0)
return base.Seek(offset, origin);
}
break;
case SeekOrigin.End:
{
if (offset != Length - Position)
return base.Seek(offset, origin);
}
break;
}
return Position;
}
开发者ID:KSLcom,项目名称:STSdb4,代码行数:26,代码来源:OptimizedFileStream.cs
示例9: Seek
public override long Seek(long offset, SeekOrigin origin)
{
int oldPosition = _Position;
switch (origin)
{
case SeekOrigin.Begin:
_Position = (int)offset;
break;
case SeekOrigin.Current:
_Position += (int)offset;
break;
case SeekOrigin.End:
_Position = _Length + (int)offset;
break;
}
if (_Position >= _Length)
{
_Position = oldPosition;
throw new IOException("");
}
return _Position;
}
开发者ID:greenboxal,项目名称:rheabase,代码行数:25,代码来源:FixedMemoryStream.cs
示例10: Seek
public override long Seek (long offset, SeekOrigin origin)
{
if (origin == SeekOrigin.Begin)
return Position = offset;
else
throw new NotSupportedException ();
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:7,代码来源:WrappedSystemStream.cs
示例11: Seek
public override long Seek(long offset, SeekOrigin origin)
{
this.ValidateSeekable();
long beginOffset = this.GetBeginOffset(offset, origin);
if ((beginOffset < this._stream.Position) &&
(beginOffset >= this._stream.Position - this._alignmentLength))
{
this._alignmentOffset = (int)(beginOffset - this._stream.Position);
}
else if (beginOffset == this._stream.Position)
{
this._alignmentOffset = 0;
this._alignmentLength = 0;
}
else
{
long alignedOffset = this.GetAlignedValue(beginOffset);
if (this._stream.Position != alignedOffset)
{
this._stream.Seek(alignedOffset, SeekOrigin.Begin);
}
this._alignmentOffset = (int)(beginOffset - alignedOffset);
this._alignmentLength = 0;
}
return beginOffset;
}
开发者ID:simony,项目名称:WinUtils,代码行数:28,代码来源:AlignedReadStream.cs
示例12: Seek
public override long Seek(long offset, SeekOrigin origin)
{
if (offset != 0L)
{
if ((offset < 0L) || ((origin != SeekOrigin.Current) && (!this.CanSeekFromBeginning || (origin != SeekOrigin.Begin))))
{
throw new ArgumentException();
}
if (this.CheckWriteOrFinished())
{
return 0L;
}
this.CanSeekFromBeginning = false;
while (offset >= (this.size - this.offset))
{
offset -= this.size - this.offset;
this.WriteEvent.Reset();
this.ReadEvent.Set();
if (this.CheckWriteOrFinished())
{
return 0L;
}
}
this.offset += (int) offset;
}
return 0L;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:27,代码来源:ReadWriteStream.cs
示例13: Seek
public void Seek(int offset, SeekOrigin origin)
{
switch (origin)
{
case SeekOrigin.Begin:
while (offset < 0)
offset += this._stringLength;
while (offset > this._stringLength)
offset -= this._stringLength;
while (offset > this.ReadedBuffer.Length)
{
this.Read();
}
this._position = offset;
break;
case SeekOrigin.Current:
this.Seek(offset + this._position, SeekOrigin.Begin);
break;
case SeekOrigin.End:
this.Seek(-offset, SeekOrigin.Begin);
break;
}
}
开发者ID:nokia6102,项目名称:jasily.cologler,代码行数:28,代码来源:SeekableStringReader.cs
示例14: Seek
public long Seek(long offset, SeekOrigin origin)
{
// no such thing as abstract in c...
// we need a vTable?
return __Stream_Seek(this, offset, origin);
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:7,代码来源:Stream.cs
示例15: MoveCursor
/// <summary>
/// Move the cursor.
/// </summary>
/// <param name="origin">Which origin to use for calculating the new
/// cursor position.</param>
/// <param name="offsetFromOrigin">The offset to apply,
/// relative to the specified origin.</param>
/// <param name="offsetFromPreviousPosition">On success, receives the
/// resulting offset moved from the previous position.</param>
/// <returns>True on success; false if the movement could not be made.
/// </returns>
public bool MoveCursor(SeekOrigin origin, int offsetFromOrigin, out int offsetFromPreviousPosition)
{
int startingIndex;
switch (origin)
{
case SeekOrigin.Begin:
startingIndex = 0;
break;
case SeekOrigin.Current:
startingIndex = CursorIndex;
break;
case SeekOrigin.End:
startingIndex = _buffer.Length;
break;
default:
throw new ArgumentOutOfRangeException(nameof(origin));
}
var newIndex = startingIndex + offsetFromOrigin;
if ((newIndex < 0) || (newIndex > _buffer.Length))
{
offsetFromPreviousPosition = 0;
return false;
}
offsetFromPreviousPosition = newIndex - CursorIndex;
CursorIndex = newIndex;
return true;
}
开发者ID:reubeno,项目名称:NClap,代码行数:44,代码来源:ConsoleInputBuffer.cs
示例16: _Seek
private long _Seek(long offset, SeekOrigin origin)
{
long toPos = 0;
var length = _blockProvider.GetLength(_path);
if (origin == SeekOrigin.Begin)
{
toPos = offset;
}
else if (origin == SeekOrigin.Current)
{
toPos = _pos + offset;
}
else if (origin == SeekOrigin.End)
{
toPos = length + offset;
}
/*
if (toPos < 0 || toPos > length)
{
throw new IOException("Invalid file position");
}
*/
if (toPos < 0)
{
throw new IOException("Invalid file position");
}
_pos = toPos;
return _pos;
}
开发者ID:Garwin4j,项目名称:BrightstarDB,代码行数:29,代码来源:BlockProviderStream.cs
示例17: SetPayload
/// <summary>
/// Extracts the contents of the given stream according to the parameters and assigns them as the response payload.
/// </summary>
/// <param name="stream">The stream from which the data is extracted.</param>
/// <param name="offset">The offset at which to begin extraction relative to the seek origin.</param>
/// <param name="length">The number of bytes to copy. Usage of a negative number means copying everything to the end of the stream.</param>
/// <param name="origin">The point from which seeking in the stream should take place.</param>
/// <returns>The response object.</returns>
public Response SetPayload(Stream stream, SeekOrigin origin, int offset = 0, int length = -1)
{
if (Disposed)
throw new ObjectDisposedException(this.GetType().FullName, "Cannot change a disposed response!");
if (stream == null)
throw new ArgumentNullException("bt", "Payload cannot be null!");
if (str != null)
try
{
str.Dispose();
}
catch { }
stream.Seek(offset, origin);
if (length < 0)
length = (int)(stream.Length - stream.Position);
var ba = new byte[length];
int read = 0;
while (read < length)
{
read += stream.Read(ba, read, length - read);
}
str = new MemoryStream(ba);
return this;
}
开发者ID:vercas,项目名称:vProto,代码行数:41,代码来源:Payload.cs
示例18: Seek
public override long Seek(long offset, SeekOrigin origin)
{
return inner.Seek(offset, origin);
}
开发者ID:BeyondVerbal-V2,项目名称:SampleClient.BvcApiV2.NET,代码行数:7,代码来源:ReadStreamWithRateControl.cs
示例19: Seek
public override long Seek(long offset, SeekOrigin origin)
{
long pos = 0;
switch (origin)
{
case SeekOrigin.Begin:
pos = offset;
break;
case SeekOrigin.Current:
pos = this.Position + offset;
break;
case SeekOrigin.End:
pos = Length + offset;
break;
}
int idx = 0;
while (idx+1 < _streamsStartPos.Count)
{
if (_streamsStartPos[idx + 1] > pos)
{
break;
}
idx++;
}
_currentStreamIndex = idx;
_currentStream = _streams[_currentStreamIndex];
_currentStream.Seek(pos - _streamsStartPos[idx], SeekOrigin.Begin);
_postion = pos;
return _postion;
//throw new InvalidOperationException("Stream is not seekable.");
}
开发者ID:frankbenoit,项目名称:combination-stream,代码行数:32,代码来源:CombinationStream.cs
示例20: Seek
public void Seek(long offset, SeekOrigin origin)
{
if ((offset != 0) || (origin != SeekOrigin.End))
{
throw new NotImplementedException();
}
}
开发者ID:mauve,项目名称:Pash,代码行数:7,代码来源:FileContentWriter.cs
注:本文中的SeekOrigin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论